<?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: Advanced WordPress Targeting with&#160;body_class_plus()</title>
	<atom:link href="http://digwp.com/2009/08/wordpress-body-class-plus/feed/" rel="self" type="application/rss+xml" />
	<link>http://digwp.com/2009/08/wordpress-body-class-plus/</link>
	<description>Learn how to take your WordPress skills to the next level.</description>
	<lastBuildDate>Sat, 20 Mar 2010 22:21:37 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jeff Starr</title>
		<link>http://digwp.com/2009/08/wordpress-body-class-plus/#comment-1910</link>
		<dc:creator>Jeff Starr</dc:creator>
		<pubDate>Mon, 05 Oct 2009 23:41:26 +0000</pubDate>
		<guid isPermaLink="false">http://digwp.com/?p=493#comment-1910</guid>
		<description>One way to do this would be via conditional tag:

&lt;code&gt;&lt;?php if(is_category(&#039;33&#039;)) { ?&gt;&lt;/code&gt;

&lt;code&gt;&lt;link href=&quot;http://domain.tld/path/special.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;&lt;/code&gt;

&lt;code&gt;} ?&gt;&lt;/code&gt;

Place in the header of your document and edit to taste.</description>
		<content:encoded><![CDATA[<p>One way to do this would be via conditional tag:</p>
<p><code>&lt;?php if(is_category('33')) { ?&gt;</code></p>
<p><code>&lt;link href="http://domain.tld/path/special.css" rel="stylesheet" type="text/css" media="screen" /&gt;</code></p>
<p><code>} ?&gt;</code></p>
<p>Place in the header of your document and edit to taste.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shawn</title>
		<link>http://digwp.com/2009/08/wordpress-body-class-plus/#comment-1787</link>
		<dc:creator>shawn</dc:creator>
		<pubDate>Mon, 28 Sep 2009 23:12:19 +0000</pubDate>
		<guid isPermaLink="false">http://digwp.com/?p=493#comment-1787</guid>
		<description>I added your function to my theme functions file and changed the body link as instructed.

Now an example body tag from a page on my site is:

Here is what I am trying to do, that I can&#039;t figure out.
I want to apply a different stylesheet to the &#039;featured-articles&#039; category.

Could you provide some example css or whatever is needed so that I can apply new styles to just that category?

I&#039;m trying to do things like change the page background image, change the font link colors etc.. pretty basic.

I don&#039;t know what you think about it, but I think it would be a great &#039;extension article&#039; to this one. Like, now you have body class..... here is how to use it, a newbie guide.

thanks</description>
		<content:encoded><![CDATA[<p>I added your function to my theme functions file and changed the body link as instructed.</p>
<p>Now an example body tag from a page on my site is:</p>
<p>Here is what I am trying to do, that I can&#8217;t figure out.<br />
I want to apply a different stylesheet to the &#8216;featured-articles&#8217; category.</p>
<p>Could you provide some example css or whatever is needed so that I can apply new styles to just that category?</p>
<p>I&#8217;m trying to do things like change the page background image, change the font link colors etc.. pretty basic.</p>
<p>I don&#8217;t know what you think about it, but I think it would be a great &#8216;extension article&#8217; to this one. Like, now you have body class&#8230;.. here is how to use it, a newbie guide.</p>
<p>thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Klark</title>
		<link>http://digwp.com/2009/08/wordpress-body-class-plus/#comment-1356</link>
		<dc:creator>Klark</dc:creator>
		<pubDate>Tue, 18 Aug 2009 23:58:50 +0000</pubDate>
		<guid isPermaLink="false">http://digwp.com/?p=493#comment-1356</guid>
		<description>Ah, I should use the add_filter too!</description>
		<content:encoded><![CDATA[<p>Ah, I should use the add_filter too!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Klark</title>
		<link>http://digwp.com/2009/08/wordpress-body-class-plus/#comment-1355</link>
		<dc:creator>Klark</dc:creator>
		<pubDate>Tue, 18 Aug 2009 23:55:55 +0000</pubDate>
		<guid isPermaLink="false">http://digwp.com/?p=493#comment-1355</guid>
		<description>I had a need to assign a body class to all pages, based on their top-most parent page. So, all children and grandchildren of /top-page/ would get the &quot;top-page&quot; body class.

I created this function in functions.php. It grabs the slug of the top most ancestor:

&lt;code&gt;function my_get_top_ancestor() {&lt;/code&gt;

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;code&gt;global $post;&lt;/code&gt;

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;code&gt;if ($post-&gt;post_parent) {&lt;/code&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;code&gt;$ancestors=get_post_ancestors($post-&gt;ID);&lt;/code&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;code&gt;$root=count($ancestors)-1;&lt;/code&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;code&gt;$parent = $ancestors[$root];&lt;/code&gt;

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;code&gt;} else {&lt;/code&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;code&gt;$parent = $post-&gt;ID;&lt;/code&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;code&gt;}&lt;/code&gt;

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;code&gt;$parentpost = get_post($parent);&lt;/code&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;code&gt;$parentslug = $parentpost-&gt;post_name;&lt;/code&gt;

&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;code&gt;return $parentslug;&lt;/code&gt;

&lt;code&gt;}&lt;/code&gt;

Then in the  tag, I have 

&lt;code&gt;&lt;body &lt;?php body_class(my_get_top_ancestor()); ?&gt;&gt;&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>I had a need to assign a body class to all pages, based on their top-most parent page. So, all children and grandchildren of /top-page/ would get the &#8220;top-page&#8221; body class.</p>
<p>I created this function in functions.php. It grabs the slug of the top most ancestor:</p>
<p><code>function my_get_top_ancestor() {</code></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>global $post;</code></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>if ($post-&gt;post_parent) {</code><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>$ancestors=get_post_ancestors($post-&gt;ID);</code><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>$root=count($ancestors)-1;</code><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>$parent = $ancestors[$root];</code></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>} else {</code><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>$parent = $post-&gt;ID;</code><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>}</code></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>$parentpost = get_post($parent);</code><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>$parentslug = $parentpost-&gt;post_name;</code></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>return $parentslug;</code></p>
<p><code>}</code></p>
<p>Then in the  tag, I have </p>
<p><code>&lt;body &lt;?php body_class(my_get_top_ancestor()); ?&gt;&gt;</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Starr</title>
		<link>http://digwp.com/2009/08/wordpress-body-class-plus/#comment-1324</link>
		<dc:creator>Jeff Starr</dc:creator>
		<pubDate>Mon, 17 Aug 2009 17:54:06 +0000</pubDate>
		<guid isPermaLink="false">http://digwp.com/?p=493#comment-1324</guid>
		<description>Awesome. I have uploaded the new version and updated the post accordingly. Later this week I will see about making it easier to add/remove classes and the matched strings. Thanks for the help!</description>
		<content:encoded><![CDATA[<p>Awesome. I have uploaded the new version and updated the post accordingly. Later this week I will see about making it easier to add/remove classes and the matched strings. Thanks for the help!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Kahoun</title>
		<link>http://digwp.com/2009/08/wordpress-body-class-plus/#comment-1322</link>
		<dc:creator>Peter Kahoun</dc:creator>
		<pubDate>Mon, 17 Aug 2009 17:15:13 +0000</pubDate>
		<guid isPermaLink="false">http://digwp.com/?p=493#comment-1322</guid>
		<description>Just fast work, needs polishing. http://kahi.cz/temp/files/work/body-class-plus-plus.php.zip</description>
		<content:encoded><![CDATA[<p>Just fast work, needs polishing. <a href="http://kahi.cz/temp/files/work/body-class-plus-plus.php.zip" rel="nofollow">http://kahi.cz/temp/files/work/body-class-plus-plus.php.zip</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Starr</title>
		<link>http://digwp.com/2009/08/wordpress-body-class-plus/#comment-1320</link>
		<dc:creator>Jeff Starr</dc:creator>
		<pubDate>Mon, 17 Aug 2009 15:16:18 +0000</pubDate>
		<guid isPermaLink="false">http://digwp.com/?p=493#comment-1320</guid>
		<description>I tried using the body_class filter, but couldn&#039;t get the PHP output buffering to play along. PHP is not my first language, so admittedly there are probably better ways of writing this code. I was actually hoping that some PHP wizards would help to improve the function.</description>
		<content:encoded><![CDATA[<p>I tried using the body_class filter, but couldn&#8217;t get the PHP output buffering to play along. PHP is not my first language, so admittedly there are probably better ways of writing this code. I was actually hoping that some PHP wizards would help to improve the function.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Starr</title>
		<link>http://digwp.com/2009/08/wordpress-body-class-plus/#comment-1319</link>
		<dc:creator>Jeff Starr</dc:creator>
		<pubDate>Mon, 17 Aug 2009 15:12:39 +0000</pubDate>
		<guid isPermaLink="false">http://digwp.com/?p=493#comment-1319</guid>
		<description>That&#039;s a great enhancement. I will be integrating something like this soon. Thanks!</description>
		<content:encoded><![CDATA[<p>That&#8217;s a great enhancement. I will be integrating something like this soon. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Darfuria</title>
		<link>http://digwp.com/2009/08/wordpress-body-class-plus/#comment-1318</link>
		<dc:creator>Darfuria</dc:creator>
		<pubDate>Mon, 17 Aug 2009 12:38:05 +0000</pubDate>
		<guid isPermaLink="false">http://digwp.com/?p=493#comment-1318</guid>
		<description>Here&#039;s the code if you&#039;re interested: http://pastebin.com/f407c3176</description>
		<content:encoded><![CDATA[<p>Here&#8217;s the code if you&#8217;re interested: <a href="http://pastebin.com/f407c3176" rel="nofollow">http://pastebin.com/f407c3176</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Kahoun</title>
		<link>http://digwp.com/2009/08/wordpress-body-class-plus/#comment-1317</link>
		<dc:creator>Peter Kahoun</dc:creator>
		<pubDate>Mon, 17 Aug 2009 12:37:59 +0000</pubDate>
		<guid isPermaLink="false">http://digwp.com/?p=493#comment-1317</guid>
		<description>There is body_class hook (filter). Much better. And preg_match() isn&#039;t neccessary here, strpos() works faster. Isn&#039;t that right?</description>
		<content:encoded><![CDATA[<p>There is body_class hook (filter). Much better. And preg_match() isn&#8217;t neccessary here, strpos() works faster. Isn&#8217;t that right?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
