<?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: Dynamic category menu highlighting for single posts</title>
	<atom:link href="http://www.studiograsshopper.ch/code-snippets/dynamic-category-menu-highlighting-for-single-posts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.studiograsshopper.ch/code-snippets/dynamic-category-menu-highlighting-for-single-posts/</link>
	<description>Wordpress site design and development, plugins, code ideas, template tags and css resources for bloggers</description>
	<lastBuildDate>Tue, 07 Feb 2012 22:11:40 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Arvid Eriksson</title>
		<link>http://www.studiograsshopper.ch/code-snippets/dynamic-category-menu-highlighting-for-single-posts/#comment-40341</link>
		<dc:creator>Arvid Eriksson</dc:creator>
		<pubDate>Fri, 16 Dec 2011 04:35:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.studiograsshopper.ch/?p=2204#comment-40341</guid>
		<description>Amazing. It works very well with my custom taxonomies! The name of my taxonomy is directors_name so this is what I put in my functions.php
&lt;code&gt;
function sgr_show_current_cat_on_single($output) { 
	global $post;
	if( is_single() ) {
		$taxonomy = &#039;directors_name&#039;;
		$categories = wp_get_object_terms( $post-&gt;ID, $taxonomy );
 
		foreach( $categories as $catid ) {
			$cat = get_category($catid);
			// Find cat-item-ID in the string
			if(preg_match(&#039;#cat-item-&#039; . $cat-&gt;cat_ID . &#039;#&#039;, $output)) {
				$output = str_replace(&#039;cat-item-&#039;.$cat-&gt;cat_ID, &#039;cat-item-&#039;.$cat-&gt;cat_ID . &#039; current-cat&#039;, $output);
			}
		}
	}
	return $output;
}

add_filter(&#039;wp_list_categories&#039;, &#039;sgr_show_current_cat_on_single&#039;);
&lt;/code&gt;

And this is what I put in my single.php
&lt;code&gt;

&lt;/code&gt;

Thank you for your help!
/ A</description>
		<content:encoded><![CDATA[<p>Amazing. It works very well with my custom taxonomies! The name of my taxonomy is directors_name so this is what I put in my functions.php<br />
<code><br />
function sgr_show_current_cat_on_single($output) {<br />
	global $post;<br />
	if( is_single() ) {<br />
		$taxonomy = 'directors_name';<br />
		$categories = wp_get_object_terms( $post-&gt;ID, $taxonomy );</p>
<p>		foreach( $categories as $catid ) {<br />
			$cat = get_category($catid);<br />
			// Find cat-item-ID in the string<br />
			if(preg_match('#cat-item-' . $cat-&gt;cat_ID . '#', $output)) {<br />
				$output = str_replace('cat-item-'.$cat-&gt;cat_ID, 'cat-item-'.$cat-&gt;cat_ID . ' current-cat', $output);<br />
			}<br />
		}<br />
	}<br />
	return $output;<br />
}</p>
<p>add_filter('wp_list_categories', 'sgr_show_current_cat_on_single');<br />
</code></p>
<p>And this is what I put in my single.php<br />
<code></p>
<p></code></p>
<p>Thank you for your help!<br />
/ A</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hansen</title>
		<link>http://www.studiograsshopper.ch/code-snippets/dynamic-category-menu-highlighting-for-single-posts/#comment-34922</link>
		<dc:creator>Hansen</dc:creator>
		<pubDate>Thu, 22 Sep 2011 08:15:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.studiograsshopper.ch/?p=2204#comment-34922</guid>
		<description>Thank you very much. It works ad hoc.</description>
		<content:encoded><![CDATA[<p>Thank you very much. It works ad hoc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ade</title>
		<link>http://www.studiograsshopper.ch/code-snippets/dynamic-category-menu-highlighting-for-single-posts/#comment-26361</link>
		<dc:creator>Ade</dc:creator>
		<pubDate>Sun, 13 Mar 2011 07:26:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.studiograsshopper.ch/?p=2204#comment-26361</guid>
		<description>Daniel,

You are quite right - the new Custom Menu functionality makes all of this so much easier. Generally, I always recommend clients to use this rather than the &quot;traditional&quot; method of wp_list_categories etc.

Glad you found the article useful.</description>
		<content:encoded><![CDATA[<p>Daniel,</p>
<p>You are quite right &#8211; the new Custom Menu functionality makes all of this so much easier. Generally, I always recommend clients to use this rather than the &#8220;traditional&#8221; method of wp_list_categories etc.</p>
<p>Glad you found the article useful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel</title>
		<link>http://www.studiograsshopper.ch/code-snippets/dynamic-category-menu-highlighting-for-single-posts/#comment-26111</link>
		<dc:creator>Daniel</dc:creator>
		<pubDate>Wed, 09 Mar 2011 09:16:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.studiograsshopper.ch/?p=2204#comment-26111</guid>
		<description>Fantastic post, and great comments too - reading it pointed me in the direction of using wp_nav_menu instead of wp_list_pages or wp_list_categories

It makes everything so easy - adding classes for the first and last list item, setting up the order of list items and also styling the parent menu item if the current page is a sub page, as discussed above

If you haven&#039;t already, do check out Justin Tadlock&#039;s excellent walk-through of wp_nav_menu here -

http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus</description>
		<content:encoded><![CDATA[<p>Fantastic post, and great comments too &#8211; reading it pointed me in the direction of using wp_nav_menu instead of wp_list_pages or wp_list_categories</p>
<p>It makes everything so easy &#8211; adding classes for the first and last list item, setting up the order of list items and also styling the parent menu item if the current page is a sub page, as discussed above</p>
<p>If you haven&#8217;t already, do check out Justin Tadlock&#8217;s excellent walk-through of wp_nav_menu here -</p>
<p><a href="http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus" rel="nofollow">http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Angelo</title>
		<link>http://www.studiograsshopper.ch/code-snippets/dynamic-category-menu-highlighting-for-single-posts/#comment-26028</link>
		<dc:creator>Angelo</dc:creator>
		<pubDate>Mon, 07 Mar 2011 19:26:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.studiograsshopper.ch/?p=2204#comment-26028</guid>
		<description>Yes....can you see the solution?...If there is I not understand it. Can you explain me, please?

I need the php code to assign current class to main categories.

Thanks</description>
		<content:encoded><![CDATA[<p>Yes&#8230;.can you see the solution?&#8230;If there is I not understand it. Can you explain me, please?</p>
<p>I need the php code to assign current class to main categories.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ade</title>
		<link>http://www.studiograsshopper.ch/code-snippets/dynamic-category-menu-highlighting-for-single-posts/#comment-26020</link>
		<dc:creator>Ade</dc:creator>
		<pubDate>Mon, 07 Mar 2011 18:00:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.studiograsshopper.ch/?p=2204#comment-26020</guid>
		<description>Angelo,

I think this is discussed elsewhere in the comments.</description>
		<content:encoded><![CDATA[<p>Angelo,</p>
<p>I think this is discussed elsewhere in the comments.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Angelo</title>
		<link>http://www.studiograsshopper.ch/code-snippets/dynamic-category-menu-highlighting-for-single-posts/#comment-25976</link>
		<dc:creator>Angelo</dc:creator>
		<pubDate>Sun, 06 Mar 2011 18:47:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.studiograsshopper.ch/?p=2204#comment-25976</guid>
		<description>Hi friends,
I followed this guide and it works great, but the single post in children categories don&#039;t active the main items menu. 

Do you have any solutions?</description>
		<content:encoded><![CDATA[<p>Hi friends,<br />
I followed this guide and it works great, but the single post in children categories don&#8217;t active the main items menu. </p>
<p>Do you have any solutions?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ade</title>
		<link>http://www.studiograsshopper.ch/code-snippets/dynamic-category-menu-highlighting-for-single-posts/#comment-24708</link>
		<dc:creator>Ade</dc:creator>
		<pubDate>Sat, 12 Feb 2011 07:54:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.studiograsshopper.ch/?p=2204#comment-24708</guid>
		<description>In fact it is much simpler if you use custom menus as WP automatically adds various classes to the menu markup. It&#039;s a question of identifying those classes (I don&#039;t know them off the top of my head) and then targeting them with appropriate CSS.</description>
		<content:encoded><![CDATA[<p>In fact it is much simpler if you use custom menus as WP automatically adds various classes to the menu markup. It&#8217;s a question of identifying those classes (I don&#8217;t know them off the top of my head) and then targeting them with appropriate CSS.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fred Rocha</title>
		<link>http://www.studiograsshopper.ch/code-snippets/dynamic-category-menu-highlighting-for-single-posts/#comment-24689</link>
		<dc:creator>Fred Rocha</dc:creator>
		<pubDate>Fri, 11 Feb 2011 15:57:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.studiograsshopper.ch/?p=2204#comment-24689</guid>
		<description>In case anyone is interested, the solution lies in using categories for the menu entries, instead of pages. As featured in &lt;a href=&quot;http://www.designisphilosophy.com/tutorials/highlight-current-page-or-category/&quot; rel=&quot;nofollow&quot;&gt;this article&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>In case anyone is interested, the solution lies in using categories for the menu entries, instead of pages. As featured in <a href="http://www.designisphilosophy.com/tutorials/highlight-current-page-or-category/" rel="nofollow">this article</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fred Rocha</title>
		<link>http://www.studiograsshopper.ch/code-snippets/dynamic-category-menu-highlighting-for-single-posts/#comment-24686</link>
		<dc:creator>Fred Rocha</dc:creator>
		<pubDate>Fri, 11 Feb 2011 11:15:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.studiograsshopper.ch/?p=2204#comment-24686</guid>
		<description>I have this very same question. How to fit this with the custom menus of version 3.x.</description>
		<content:encoded><![CDATA[<p>I have this very same question. How to fit this with the custom menus of version 3.x.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

