<?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: Unique Body ID&#8217;s for your Pages</title>
	<atom:link href="http://digwp.com/2009/05/unique-body-ids-for-your-pages/feed/" rel="self" type="application/rss+xml" />
	<link>http://digwp.com/2009/05/unique-body-ids-for-your-pages/</link>
	<description>Take your WordPress skills to the next level.</description>
	<lastBuildDate>Tue, 15 May 2012 08:36:23 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Jason</title>
		<link>http://digwp.com/2009/05/unique-body-ids-for-your-pages/#comment-646</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Sat, 11 Jul 2009 01:08:25 +0000</pubDate>
		<guid isPermaLink="false">http://modernwordpress.com/?p=18#comment-646</guid>
		<description>This can be even better, and avoids the little commented out bit that I wrote above if used the following way:

&lt;code&gt;function body_id() {&lt;/code&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;code&gt;$url = explode(get_option(&#039;siteurl&#039;), $_SERVER[&#039;REQUEST_URI&#039;]);&lt;/code&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;code&gt;$dir = $url[1] ? $url[1] : &#039;home&#039;;&lt;/code&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&lt;code&gt;echo &#039;id=&quot;&#039; . $dir . &#039;&quot;&#039;;&lt;/code&gt;
&lt;code&gt;}&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>This can be even better, and avoids the little commented out bit that I wrote above if used the following way:</p>
<p><code>function body_id() {</code><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>$url = explode(get_option('siteurl'), $_SERVER['REQUEST_URI']);</code><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>$dir = $url[1] ? $url[1] : 'home';</code><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>echo 'id="' . $dir . '"';</code><br />
<code>}</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://digwp.com/2009/05/unique-body-ids-for-your-pages/#comment-214</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Mon, 22 Jun 2009 21:45:19 +0000</pubDate>
		<guid isPermaLink="false">http://modernwordpress.com/?p=18#comment-214</guid>
		<description>Also, one more thing. Probably cleaner to put your code in the functions.php file, and when developing locally I had to change url[1] to url[2] since my folder name gets put in front of the actual page title, http://localhost/site-name/page-name:
&lt;code&gt;
function body_id() {
	$url = explode(&#039;/&#039;,$_SERVER[&#039;REQUEST_URI&#039;]);
	// USE WHEN LIVE
	//$dir = $url[1] ? $url[1] : &#039;home&#039;; 

	// USE WHEN LOCAL
	$dir = $url[2] ? $url[2] : &#039;home&#039;;
	echo &#039;id=&quot;&#039; . $dir . &#039;&quot;&#039;;
}
&lt;/code&gt;

and then call this in the header.php file:
&lt;code&gt;
&lt;body &lt;?php body_id(); ?&gt; &lt;?php body_class(); ?&gt;&gt;
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Also, one more thing. Probably cleaner to put your code in the functions.php file, and when developing locally I had to change url[1] to url[2] since my folder name gets put in front of the actual page title, <a href="http://localhost/site-name/page-name" rel="nofollow">http://localhost/site-name/page-name</a>:<br />
<pre><code>
function body_id() {
	$url = explode('/',$_SERVER['REQUEST_URI']);
	// USE WHEN LIVE
	//$dir = $url[1] ? $url[1] : 'home'; 

	// USE WHEN LOCAL
	$dir = $url[2] ? $url[2] : 'home';
	echo 'id="' . $dir . '"';
}
</code></pre></p>
<p>and then call this in the header.php file:<br />
<pre><code>
&lt;body &lt;?php body_id(); ?&gt; &lt;?php body_class(); ?&gt;&gt;
</code></pre></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://digwp.com/2009/05/unique-body-ids-for-your-pages/#comment-213</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Mon, 22 Jun 2009 21:30:36 +0000</pubDate>
		<guid isPermaLink="false">http://modernwordpress.com/?p=18#comment-213</guid>
		<description>I&#039;ve noticed that WordPress 2.8 (I don&#039;t think the earlier versions had this?) has a php function call in the body tag called body_class();

The body_class() function calls get_body_class and concatenates all possible classes, e.g: home, blog, archive, date, search, paged, attachment, and error404... and a unique post / page id class like page-id-4 or postid-3. This is only a problem if you want to use unique identifiers the absolute correct way...with an id attribute as opposed to a class attribute.

Anyway, I like the solution Chris, more elegant than what I was using...which was to use php to lowercase the slug and replace white-space with underscores:
&lt;code&gt;
&lt;body id=&quot;&lt;?php $title = get_the_title();
$lowercaseTitle = strtolower($title);
echo str_replace(&quot; &quot;, &quot;_&quot;, $lowercaseTitle); ?&gt;&quot;&gt;
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>I&#8217;ve noticed that WordPress 2.8 (I don&#8217;t think the earlier versions had this?) has a php function call in the body tag called body_class();</p>
<p>The body_class() function calls get_body_class and concatenates all possible classes, e.g: home, blog, archive, date, search, paged, attachment, and error404&#8230; and a unique post / page id class like page-id-4 or postid-3. This is only a problem if you want to use unique identifiers the absolute correct way&#8230;with an id attribute as opposed to a class attribute.</p>
<p>Anyway, I like the solution Chris, more elegant than what I was using&#8230;which was to use php to lowercase the slug and replace white-space with underscores:<br />
<pre><code>
&lt;body id="&lt;?php $title = get_the_title();
$lowercaseTitle = strtolower($title);
echo str_replace(" ", "_", $lowercaseTitle); ?&gt;"&gt;
</code></pre></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ian Rountree</title>
		<link>http://digwp.com/2009/05/unique-body-ids-for-your-pages/#comment-146</link>
		<dc:creator>Ian Rountree</dc:creator>
		<pubDate>Fri, 19 Jun 2009 05:04:37 +0000</pubDate>
		<guid isPermaLink="false">http://modernwordpress.com/?p=18#comment-146</guid>
		<description>Very slick! But would there be a way to make this more dynamic? For example, rather than creating specifically designed templates, serving up some choice php based solely on categories or post vs page? Red headers for news posts, blue for errata and so on?</description>
		<content:encoded><![CDATA[<p>Very slick! But would there be a way to make this more dynamic? For example, rather than creating specifically designed templates, serving up some choice php based solely on categories or post vs page? Red headers for news posts, blue for errata and so on?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Taylor</title>
		<link>http://digwp.com/2009/05/unique-body-ids-for-your-pages/#comment-22</link>
		<dc:creator>Chris Taylor</dc:creator>
		<pubDate>Tue, 16 Jun 2009 14:43:22 +0000</pubDate>
		<guid isPermaLink="false">http://modernwordpress.com/?p=18#comment-22</guid>
		<description>Nice tip.

I&#039;ve also used this before which uses the current page&#039;s slug as the body class. 

&lt;code&gt;ID); // get current post or page
    	$slug = $post_id-&gt;post_name; // define slug as $slug
		if (is_home()) {
            $slug = &quot;news&quot;;
		} else {
		}
		?&gt;
	
	&lt;body class=&quot;&quot;&gt;&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Nice tip.</p>
<p>I&#8217;ve also used this before which uses the current page&#8217;s slug as the body class. </p>
<p><pre><code>ID); // get current post or page
    	$slug = $post_id-&gt;post_name; // define slug as $slug
		if (is_home()) {
            $slug = "news";
		} else {
		}
		?&gt;
	
	&lt;body class=""&gt;</code></pre></p>
]]></content:encoded>
	</item>
</channel>
</rss>

