<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>... coding (the life) &#187; post2cat</title>
	<atom:link href="http://www.marvinmarcelo.com/tag/post2cat/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.marvinmarcelo.com</link>
	<description>Anything about programming, and a little about me.</description>
	<lastBuildDate>Mon, 09 Jan 2012 13:44:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>WordPress</title>
		<link>http://www.marvinmarcelo.com/wordpress/</link>
		<comments>http://www.marvinmarcelo.com/wordpress/#comments</comments>
		<pubDate>Sun, 27 Jul 2008 01:34:28 +0000</pubDate>
		<dc:creator>Marvin</dc:creator>
				<category><![CDATA[work related]]></category>
		<category><![CDATA[category-tagging]]></category>
		<category><![CDATA[post2cat]]></category>
		<category><![CDATA[sos]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.marvinmarcelo.com/?p=55</guid>
		<description><![CDATA[Changes to my wordpress theme so that cattag_related_posts function will work. I&#8217;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 &#8230; <a href="http://www.marvinmarcelo.com/wordpress/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Changes to my wordpress theme so that <code>cattag_related_posts</code> function will work. I&#8217;m using <a href="http://milo.peety-passion.com/category/themes/">Ice</a> theme by <a href="http://milo.peety-passion.com/">miloIIIIVII</a> and inside the theme functions file is the embeded plugin <a href="http://blog.bull3t.me.uk/projects/category-tagging/">Category Tagging</a> by <a href="http://www.bull3t.me.uk/">Bull3t</a>. And guess what, it still reference some column from <code>post2cat</code> table which DOES NOT exists in my version.</p>
<p>It looks like wordpress is not going to release a fix when they dropped <a href="http://wordpress.org/tags/wp_post2cat">post2cat</a> table, starting from the 2.3 release. Or, I just haven&#8217;t found their fix on this. I also noticed this when the client I&#8217;m working for at <a href="http://www.staffoffshore.com/">Staff Off Shore</a> decided to upgrade his blog site. What I did is modify that block of code and use the <code>term_relationships</code> instead to come up with this SQL and return similar results.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">mysql <span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #993333; font-weight: bold;">DISTINCT</span> p<span style="color: #66cc66;">.</span>ID<span style="color: #66cc66;">,</span> p<span style="color: #66cc66;">.</span>post_title <span style="color: #993333; font-weight: bold;">FROM</span> blog_posts p
      <span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">JOIN</span> blog_term_relationships tr <span style="color: #993333; font-weight: bold;">ON</span> p<span style="color: #66cc66;">.</span>ID <span style="color: #66cc66;">=</span> tr<span style="color: #66cc66;">.</span>object_id
      <span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">WHERE</span> p<span style="color: #66cc66;">.</span>post_status <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'publish'</span> <span style="color: #993333; font-weight: bold;">AND</span> p<span style="color: #66cc66;">.</span>ID <span style="color: #66cc66;">&lt;&gt;</span> <span style="color: #cc66cc;">55</span>
      <span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">AND</span> p<span style="color: #66cc66;">.</span>post_type <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'post'</span> <span style="color: #993333; font-weight: bold;">AND</span> tr<span style="color: #66cc66;">.</span>term_taxonomy_id <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span>
      <span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> p<span style="color: #66cc66;">.</span>post_date <span style="color: #993333; font-weight: bold;">DESC</span> <span style="color: #993333; font-weight: bold;">LIMIT</span> <span style="color: #cc66cc;">5</span>;</pre></div></div>

<p>I have uploaded a version of <code>cattag_related_posts</code> function and it needs to be patch to any existing theme functions file (functions.php) or the &#8220;category-tagging&#8221; plugin that still queries on &#8220;wp_post2cat&#8221; table. This is what I am using, example of which are the items under &#8220;Possibly Related&#8221; header below this post (not the google of course).</p>
<p>Use it in your template like so, though I think I disabled the $exclude_ids parameter for now, but it should work without it.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">cattag_related_posts<span style="color: #009900;">&#40;</span>
	<span style="color: #000088;">$limit</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span>		<span style="color: #666666; font-style: italic;"># number of posts to return
</span>	<span style="color: #000088;">$display_posts</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span>	<span style="color: #666666; font-style: italic;"># swap values with display_page
</span>	<span style="color: #000088;">$display_pages</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span>	<span style="color: #666666; font-style: italic;"># to get post or page
</span>	<span style="color: #000088;">$before</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;li&gt;'</span><span style="color: #339933;">,</span>	<span style="color: #666666; font-style: italic;"># html wrapper
</span>	<span style="color: #000088;">$after</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;/li&gt;'</span><span style="color: #339933;">,</span>
	<span style="color: #000088;">$notfound</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span>
	<span style="color: #000088;">$order</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'DATE_DESC'</span><span style="color: #339933;">,</span>	<span style="color: #666666; font-style: italic;"># DATE_DESC or RANDOM
</span>	<span style="color: #000088;">$exclude_ids</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Download: <a href="/wp-content/uploads/2008/07/cattag_related_posts.txt">cattag_related_posts.txt</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.marvinmarcelo.com/wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

