Posts Tagged ‘post2cat’
27
Jul
Changes to my wordpress theme so that cattag_related_posts function will work. I’m using Ice theme by miloIIIIVII and inside the theme functions file is the embeded plugin Category Tagging by Bull3t. And guess what, it still reference some column from post2cat table which DOES NOT exists in my version.
It looks like wordpress is not going to release a fix when they dropped post2cat table, starting from the 2.3 release. Or, I just haven’t found their fix on this. I also noticed this when the client I’m working for at Staff Off Shore decided to upgrade his blog site. What I did is modify that block of code and use the term_relationships instead to come up with this SQL and return similar results.
mysql > SELECT DISTINCT p.ID, p.post_title FROM blog_posts p > LEFT JOIN blog_term_relationships tr ON p.ID = tr.object_id > WHERE p.post_status = 'publish' AND p.ID <> 55 > AND p.post_type = 'post' AND tr.term_taxonomy_id IN (4) > ORDER BY p.post_date DESC LIMIT 5;
I have uploaded a version of cattag_related_posts function and it needs to be patch to any existing theme functions file (functions.php) or the “category-tagging” plugin that still queries on “wp_post2cat” table. This is what I am using, example of which are the items under “Possibly Related” header below this post (not the google of course).
Use it in your template like so, though I think I disabled the $exclude_ids parameter for now, but it should work without it.
1 2 3 4 5 6 7 8 9 10 | cattag_related_posts( $limit = 5, # number of posts to return $display_posts = true, # swap values with display_page $display_pages = false, # to get post or page $before = '<li>', # html wrapper $after = '</li>', $notfound = false, $order = 'DATE_DESC', # DATE_DESC or RANDOM $exclude_ids = '' ); |
Download: cattag_related_posts.txt
Tags: category-tagging, post2cat, sos, wordpress
Posted in work related | No Comments »


