<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Retrieving the categories of a blog post in WordPress</title>
	<atom:link href="http://sudarmuthu.com/blog/2009/02/22/retrieving-the-categories-of-a-blog-post-in-wordpress.html/feed" rel="self" type="application/rss+xml" />
	<link>http://sudarmuthu.com/blog/2009/02/22/retrieving-the-categories-of-a-blog-post-in-wordpress.html</link>
	<description>WordPress, JavaScript, Android and some random stuff</description>
	<lastBuildDate>Fri, 30 Jul 2010 13:51:32 +0530</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Hannah</title>
		<link>http://sudarmuthu.com/blog/2009/02/22/retrieving-the-categories-of-a-blog-post-in-wordpress.html#comment-586646</link>
		<dc:creator>Hannah</dc:creator>
		<pubDate>Wed, 02 Jun 2010 21:05:17 +0000</pubDate>
		<guid isPermaLink="false">http://sudarmuthu.com/?p=453#comment-586646</guid>
		<description>Love your blog!. I really enjoy reading all of the posts. Keep up the good work! :)</description>
		<content:encoded><![CDATA[<p>Love your blog!. I really enjoy reading all of the posts. Keep up the good work! <img src='http://sudarmuthu.com/wpfiles/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: uwiuw</title>
		<link>http://sudarmuthu.com/blog/2009/02/22/retrieving-the-categories-of-a-blog-post-in-wordpress.html#comment-580329</link>
		<dc:creator>uwiuw</dc:creator>
		<pubDate>Mon, 29 Mar 2010 10:36:46 +0000</pubDate>
		<guid isPermaLink="false">http://sudarmuthu.com/?p=453#comment-580329</guid>
		<description>great, i&#039;m also have problem when i have to retrieve category of particular post. Now, i got what i need. thank you very much, especially wp_get_post_categories function is so dependable. I can use it in some early load hook such as pre_get_post...thanks

btw, while you got headache for two days, i got it for a day. hehehe just intermezzo</description>
		<content:encoded><![CDATA[<p>great, i&#8217;m also have problem when i have to retrieve category of particular post. Now, i got what i need. thank you very much, especially wp_get_post_categories function is so dependable. I can use it in some early load hook such as pre_get_post&#8230;thanks</p>
<p>btw, while you got headache for two days, i got it for a day. hehehe just intermezzo</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sudar</title>
		<link>http://sudarmuthu.com/blog/2009/02/22/retrieving-the-categories-of-a-blog-post-in-wordpress.html#comment-576383</link>
		<dc:creator>Sudar</dc:creator>
		<pubDate>Sat, 23 Jan 2010 13:41:39 +0000</pubDate>
		<guid isPermaLink="false">http://sudarmuthu.com/?p=453#comment-576383</guid>
		<description>@Alexandre,

The above code will only output the list of categories. To highlight the current category to which the post belongs, you have to get the category of the current post in your single.php template of your theme and then add the corresponding highlight class to the category.</description>
		<content:encoded><![CDATA[<p>@Alexandre,</p>
<p>The above code will only output the list of categories. To highlight the current category to which the post belongs, you have to get the category of the current post in your single.php template of your theme and then add the corresponding highlight class to the category.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sudar</title>
		<link>http://sudarmuthu.com/blog/2009/02/22/retrieving-the-categories-of-a-blog-post-in-wordpress.html#comment-576382</link>
		<dc:creator>Sudar</dc:creator>
		<pubDate>Sat, 23 Jan 2010 13:36:43 +0000</pubDate>
		<guid isPermaLink="false">http://sudarmuthu.com/?p=453#comment-576382</guid>
		<description>@Helio,

I would recommend that you do it using WordPress API. If you are going to use WordPress API, then the above code will work.</description>
		<content:encoded><![CDATA[<p>@Helio,</p>
<p>I would recommend that you do it using WordPress API. If you are going to use WordPress API, then the above code will work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Helio</title>
		<link>http://sudarmuthu.com/blog/2009/02/22/retrieving-the-categories-of-a-blog-post-in-wordpress.html#comment-575144</link>
		<dc:creator>Helio</dc:creator>
		<pubDate>Tue, 12 Jan 2010 02:49:56 +0000</pubDate>
		<guid isPermaLink="false">http://sudarmuthu.com/?p=453#comment-575144</guid>
		<description>Hi Sudar,

Thank you very much for this post, this is pretty much what I&#039;m looking for. Actually I&#039;d like to move my wordpress blog to a Joomla platform. I found a plug-in that works only half, it does import the posts and the categories but it does not link the posts to the category.

Do you know how I could achieve this in PHP not using Wordpress API.
Do you think I could use your code:
&lt;code&gt;
    foreach ($posts as $post) {
      $new_cats = array(5,10);
      wp_update_post(array(&#039;ID&#039;=&gt;$post-&gt;ID,&#039;post_category&#039;=&gt;$new_cats));
    }
&lt;/code&gt;
To add the category name to the field post_category since it has been deprecated and then with a simple query retrieve his field and assign it to the post&#039;s category into the Joomla database.

Thanks again for this precious post.

Helio</description>
		<content:encoded><![CDATA[<p>Hi Sudar,</p>
<p>Thank you very much for this post, this is pretty much what I&#8217;m looking for. Actually I&#8217;d like to move my wordpress blog to a Joomla platform. I found a plug-in that works only half, it does import the posts and the categories but it does not link the posts to the category.</p>
<p>Do you know how I could achieve this in PHP not using Wordpress API.<br />
Do you think I could use your code:<br />
<code><br />
    foreach ($posts as $post) {<br />
      $new_cats = array(5,10);<br />
      wp_update_post(array('ID'=&gt;$post-&gt;ID,'post_category'=&gt;$new_cats));<br />
    }<br />
</code><br />
To add the category name to the field post_category since it has been deprecated and then with a simple query retrieve his field and assign it to the post&#8217;s category into the Joomla database.</p>
<p>Thanks again for this precious post.</p>
<p>Helio</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexandre</title>
		<link>http://sudarmuthu.com/blog/2009/02/22/retrieving-the-categories-of-a-blog-post-in-wordpress.html#comment-574957</link>
		<dc:creator>Alexandre</dc:creator>
		<pubDate>Sun, 10 Jan 2010 11:54:12 +0000</pubDate>
		<guid isPermaLink="false">http://sudarmuthu.com/?p=453#comment-574957</guid>
		<description>Sudar,

Thanks a lot! That post really helps to get 50% of my problem solved. May i ask if you could help with the remaining 50%?

I use a category menu to navigate on my blog. I output this menu using :

    wp_list_categories(&#039;child_of=55&amp;sort_column=menu_order&amp;sort_order=asc&amp;title_li=&#039;);


Now, if i look at one of the posts inside that category, that category is not highlighted in the category menu: the current-cat class is not added.

Am i doing something wrong or is this a bug?

Thanks a lot for your insight!

Alexandre</description>
		<content:encoded><![CDATA[<p>Sudar,</p>
<p>Thanks a lot! That post really helps to get 50% of my problem solved. May i ask if you could help with the remaining 50%?</p>
<p>I use a category menu to navigate on my blog. I output this menu using :</p>
<p>    wp_list_categories(&#8216;child_of=55&amp;sort_column=menu_order&amp;sort_order=asc&amp;title_li=&#8217;);</p>
<p>Now, if i look at one of the posts inside that category, that category is not highlighted in the category menu: the current-cat class is not added.</p>
<p>Am i doing something wrong or is this a bug?</p>
<p>Thanks a lot for your insight!</p>
<p>Alexandre</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sudar</title>
		<link>http://sudarmuthu.com/blog/2009/02/22/retrieving-the-categories-of-a-blog-post-in-wordpress.html#comment-548010</link>
		<dc:creator>Sudar</dc:creator>
		<pubDate>Wed, 19 Aug 2009 06:01:44 +0000</pubDate>
		<guid isPermaLink="false">http://sudarmuthu.com/?p=453#comment-548010</guid>
		<description>Nice to know that it was of help to you.

And yeah, &quot;God bless the web&quot; ;)</description>
		<content:encoded><![CDATA[<p>Nice to know that it was of help to you.</p>
<p>And yeah, &#8220;God bless the web&#8221; <img src='http://sudarmuthu.com/wpfiles/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sudar</title>
		<link>http://sudarmuthu.com/blog/2009/02/22/retrieving-the-categories-of-a-blog-post-in-wordpress.html#comment-548008</link>
		<dc:creator>Sudar</dc:creator>
		<pubDate>Wed, 19 Aug 2009 06:00:46 +0000</pubDate>
		<guid isPermaLink="false">http://sudarmuthu.com/?p=453#comment-548008</guid>
		<description>&lt;blockquote&gt;
Nice. The first result from Google searching for:
how to retrieve the category from a wordpress post
&lt;/blockquote&gt;
The main reason why I posted about this is that, people searching for the same problem could find out the solution. Nice to know that you found it out.</description>
		<content:encoded><![CDATA[<blockquote><p>
Nice. The first result from Google searching for:<br />
how to retrieve the category from a wordpress post
</p></blockquote>
<p>The main reason why I posted about this is that, people searching for the same problem could find out the solution. Nice to know that you found it out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: goosy</title>
		<link>http://sudarmuthu.com/blog/2009/02/22/retrieving-the-categories-of-a-blog-post-in-wordpress.html#comment-517729</link>
		<dc:creator>goosy</dc:creator>
		<pubDate>Sat, 20 Jun 2009 03:47:49 +0000</pubDate>
		<guid isPermaLink="false">http://sudarmuthu.com/?p=453#comment-517729</guid>
		<description>Pfiou you are the man ! thanks for the help :)
God bless the web</description>
		<content:encoded><![CDATA[<p>Pfiou you are the man ! thanks for the help <img src='http://sudarmuthu.com/wpfiles/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
God bless the web</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://sudarmuthu.com/blog/2009/02/22/retrieving-the-categories-of-a-blog-post-in-wordpress.html#comment-517646</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Fri, 19 Jun 2009 23:46:39 +0000</pubDate>
		<guid isPermaLink="false">http://sudarmuthu.com/?p=453#comment-517646</guid>
		<description>Nice. The first result from Google searching for:
how to retrieve the category from a wordpress post

Excellent.</description>
		<content:encoded><![CDATA[<p>Nice. The first result from Google searching for:<br />
how to retrieve the category from a wordpress post</p>
<p>Excellent.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Everyday learning&#8217;s as a web developer - Night Dreaming (by Sudar)</title>
		<link>http://sudarmuthu.com/blog/2009/02/22/retrieving-the-categories-of-a-blog-post-in-wordpress.html#comment-495908</link>
		<dc:creator>Everyday learning&#8217;s as a web developer - Night Dreaming (by Sudar)</dc:creator>
		<pubDate>Tue, 28 Apr 2009 18:05:13 +0000</pubDate>
		<guid isPermaLink="false">http://sudarmuthu.com/?p=453#comment-495908</guid>
		<description>[...] retrieving the categories of a post. I wrote about it and almost forgot about it till I received a comment from a person called kaigou Insert OMFG or variant thereof, about twenty times, at two in the morning. I’ve been fighting [...]</description>
		<content:encoded><![CDATA[<p>[...] retrieving the categories of a post. I wrote about it and almost forgot about it till I received a comment from a person called kaigou Insert OMFG or variant thereof, about twenty times, at two in the morning. I’ve been fighting [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sudar</title>
		<link>http://sudarmuthu.com/blog/2009/02/22/retrieving-the-categories-of-a-blog-post-in-wordpress.html#comment-487996</link>
		<dc:creator>Sudar</dc:creator>
		<pubDate>Wed, 15 Apr 2009 08:18:40 +0000</pubDate>
		<guid isPermaLink="false">http://sudarmuthu.com/?p=453#comment-487996</guid>
		<description>@Kaigou,

Wow!! It was really a nice feeling to know that my post was of soo much help to you. :) Your comment has brought a nice big smile on my face and thanks for that :)</description>
		<content:encoded><![CDATA[<p>@Kaigou,</p>
<p>Wow!! It was really a nice feeling to know that my post was of soo much help to you. <img src='http://sudarmuthu.com/wpfiles/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Your comment has brought a nice big smile on my face and thanks for that <img src='http://sudarmuthu.com/wpfiles/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kaigou</title>
		<link>http://sudarmuthu.com/blog/2009/02/22/retrieving-the-categories-of-a-blog-post-in-wordpress.html#comment-487961</link>
		<dc:creator>kaigou</dc:creator>
		<pubDate>Wed, 15 Apr 2009 06:58:40 +0000</pubDate>
		<guid isPermaLink="false">http://sudarmuthu.com/?p=453#comment-487961</guid>
		<description>Insert OMFG or variant thereof, about twenty times, at two in the morning. I&#039;ve been fighting with WP all day to get it to do what I want, and the WP docs have been useless -- maybe it&#039;s just that most folks don&#039;t really get into really doing wacky things like nested loops and whatnot, I suppose. I was about to give up when behold, the power of google dropped your post on my screen and NOW IT WORKS. I feel like a keyboard mash is due, or buying you a virtual drink, or SOMETHING. May have to settle for quietly dancing around the house in glee, given that it is two in the morning when most non-geeky souls are quietly abed. But not me! Must celebrate your awesomeness for helping me finally getting it to work! Thank you!!!</description>
		<content:encoded><![CDATA[<p>Insert OMFG or variant thereof, about twenty times, at two in the morning. I&#8217;ve been fighting with WP all day to get it to do what I want, and the WP docs have been useless &#8212; maybe it&#8217;s just that most folks don&#8217;t really get into really doing wacky things like nested loops and whatnot, I suppose. I was about to give up when behold, the power of google dropped your post on my screen and NOW IT WORKS. I feel like a keyboard mash is due, or buying you a virtual drink, or SOMETHING. May have to settle for quietly dancing around the house in glee, given that it is two in the morning when most non-geeky souls are quietly abed. But not me! Must celebrate your awesomeness for helping me finally getting it to work! Thank you!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sudar</title>
		<link>http://sudarmuthu.com/blog/2009/02/22/retrieving-the-categories-of-a-blog-post-in-wordpress.html#comment-471348</link>
		<dc:creator>Sudar</dc:creator>
		<pubDate>Wed, 18 Mar 2009 18:28:05 +0000</pubDate>
		<guid isPermaLink="false">http://sudarmuthu.com/?p=453#comment-471348</guid>
		<description>@Matt,

Nice to know that my post was of use to you. I didn&#039;t know about wp_set_post_categories() function. I will try to use it and will update the post about it. Thanks!</description>
		<content:encoded><![CDATA[<p>@Matt,</p>
<p>Nice to know that my post was of use to you. I didn&#8217;t know about wp_set_post_categories() function. I will try to use it and will update the post about it. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://sudarmuthu.com/blog/2009/02/22/retrieving-the-categories-of-a-blog-post-in-wordpress.html#comment-471293</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Wed, 18 Mar 2009 11:15:48 +0000</pubDate>
		<guid isPermaLink="false">http://sudarmuthu.com/?p=453#comment-471293</guid>
		<description>Thanks for the post.  Just looking for the same thing - however, wp_update_post didn&#039;t seem to work.  Instead, I noticed there is a function called wp_set_post_categories($postId, array(cat1ID, cat2ID, ...)), which worked perfectly.</description>
		<content:encoded><![CDATA[<p>Thanks for the post.  Just looking for the same thing &#8211; however, wp_update_post didn&#8217;t seem to work.  Instead, I noticed there is a function called wp_set_post_categories($postId, array(cat1ID, cat2ID, &#8230;)), which worked perfectly.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
