<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.1.3" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Wordpress tutorial:how to apply a dynamic body class or&#160;ID</title>
	<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/</link>
	<description>Elliot Jay Stocks is Senior Designer at Carson Systems and his work is regularly published worldwide. He's also a writer and musician... of sorts.</description>
	<pubDate>Mon, 06 Oct 2008 16:01:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.3</generator>

	<item>
		<title>By: Sam Brown</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1339</link>
		<author>Sam Brown</author>
		<pubDate>Sat, 23 Feb 2008 15:00:00 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1339</guid>
					<description>Cool technique, I may have to convert it for use in my CMS of choice Textpattern.

Are you still using TextMate to code your sites?</description>
		<content:encoded><![CDATA[<p>Cool technique, I may have to convert it for use in my CMS of choice Textpattern.</p>
<p>Are you still using TextMate to code your sites?</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: DigiKev</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1340</link>
		<author>DigiKev</author>
		<pubDate>Sat, 23 Feb 2008 15:12:08 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1340</guid>
					<description>This is a fantastic tutorial Elliot and opens up a whole new bunch of opportunities.  I too have started using WordPress again recently and also have a couple of websites I am builidng for a client with WordPress as the CMS engine to keep costs down.  Sure this method will come in handy.</description>
		<content:encoded><![CDATA[<p>This is a fantastic tutorial Elliot and opens up a whole new bunch of opportunities.  I too have started using WordPress again recently and also have a couple of websites I am builidng for a client with WordPress as the CMS engine to keep costs down.  Sure this method will come in handy.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Mark</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1341</link>
		<author>Mark</author>
		<pubDate>Sat, 23 Feb 2008 15:12:11 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1341</guid>
					<description>When you make sites for friends or smaller sized sites in general, maybe you fall in love with the very good cms called symphony (&lt;a href="http://www.symphony21.com" rel="nofollow"&gt;www.symphony21.com&lt;/a&gt;).

I'm also a newby to it, but after a day you can do all the basic xml/xslt-stuff to create very dynamic pages with a beautiful backend. My first project with symphony was &lt;a href="http://jugendwerkstatt-steimke.de" rel="nofollow"&gt;this&lt;/a&gt;. I created the page about a year ago by hand with my own crappy php-solution. A week ago I adapted it to symphony in about two days. 

I never did a wordpress theme, but everytime I looked at the themes they seemed to me very complex and hard to handle, which is far more easy in symphony. 

A css-class for every section of a site would be the code of:
&lt;code&gt;body class="{$current-page}" &lt;/code&gt;
which is really cool.</description>
		<content:encoded><![CDATA[<p>When you make sites for friends or smaller sized sites in general, maybe you fall in love with the very good cms called symphony (<a href="http://www.symphony21.com" rel="nofollow">www.symphony21.com</a>).</p>
<p>I&#8217;m also a newby to it, but after a day you can do all the basic xml/xslt-stuff to create very dynamic pages with a beautiful backend. My first project with symphony was <a href="http://jugendwerkstatt-steimke.de" rel="nofollow">this</a>. I created the page about a year ago by hand with my own crappy php-solution. A week ago I adapted it to symphony in about two days. </p>
<p>I never did a wordpress theme, but everytime I looked at the themes they seemed to me very complex and hard to handle, which is far more easy in symphony. </p>
<p>A css-class for every section of a site would be the code of:<br />
<code>body class="{$current-page}" </code><br />
which is really cool.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Brian Cobb</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1342</link>
		<author>Brian Cobb</author>
		<pubDate>Sat, 23 Feb 2008 15:14:18 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1342</guid>
					<description>I like it. Keeps things well organized and easily extensible. Could you utilize this technique with calling multiple style sheets to only load the styles you &lt;em&gt;need&lt;/em&gt; for the page? So you'd have a general style sheet for consistent elements, and then load page-based styles as needed, again based on filename.</description>
		<content:encoded><![CDATA[<p>I like it. Keeps things well organized and easily extensible. Could you utilize this technique with calling multiple style sheets to only load the styles you <em>need</em> for the page? So you&#8217;d have a general style sheet for consistent elements, and then load page-based styles as needed, again based on filename.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: prisca</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1343</link>
		<author>prisca</author>
		<pubDate>Sat, 23 Feb 2008 15:16:02 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1343</guid>
					<description>thanks for the post, Elliot ;) 

very much into WordPress myself at the moment - just got to love it :)
will have a go at using your technique in my next project - thanks for sharing :)

PS: and thanks again for your starker's theme - saving me loads of time these days :)</description>
		<content:encoded><![CDATA[<p>thanks for the post, Elliot ;) </p>
<p>very much into WordPress myself at the moment - just got to love it :)<br />
will have a go at using your technique in my next project - thanks for sharing :)</p>
<p>PS: and thanks again for your starker&#8217;s theme - saving me loads of time these days :)</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Laura</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1344</link>
		<author>Laura</author>
		<pubDate>Sat, 23 Feb 2008 15:23:55 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1344</guid>
					<description>Another way to tackle this is through the use of custom page templates. If you're just changing one item, like adding a body class, your method is neater and quicker. But if find yourself in a situation where you want to do a few things to individualize a page (one I recently did included different sidebar content for each page, for example), you can create a custom page template for it.

Essentially, what you do is take the normal page template, make the changes you need to, add save it with another name (like page-film.php and page-links.php, etc.) You need to include this code at the top:

(See &lt;a href="http://codex.wordpress.org/Pages#Creating_your_own_Page_Templates" rel="nofollow"&gt;here&lt;/a&gt;.)

Then, when you're writing the page's content, open the Page Template bar on the right side of the edit screen and choose the appropriate template from the list. The templates can be used over and over if your site calls for it; for example, if you create a special page template for Personnel or somesuch, you could have each person have their own page, each using the Personnel template.

Like I said, this may be overkill if you only want to add a class or something like that, but it's awesome for fine-tuned control when you need a certain page or pages to have individualized content. Super powerful!</description>
		<content:encoded><![CDATA[<p>Another way to tackle this is through the use of custom page templates. If you&#8217;re just changing one item, like adding a body class, your method is neater and quicker. But if find yourself in a situation where you want to do a few things to individualize a page (one I recently did included different sidebar content for each page, for example), you can create a custom page template for it.</p>
<p>Essentially, what you do is take the normal page template, make the changes you need to, add save it with another name (like page-film.php and page-links.php, etc.) You need to include this code at the top:</p>
<p>(See <a href="http://codex.wordpress.org/Pages#Creating_your_own_Page_Templates" rel="nofollow">here</a>.)</p>
<p>Then, when you&#8217;re writing the page&#8217;s content, open the Page Template bar on the right side of the edit screen and choose the appropriate template from the list. The templates can be used over and over if your site calls for it; for example, if you create a special page template for Personnel or somesuch, you could have each person have their own page, each using the Personnel template.</p>
<p>Like I said, this may be overkill if you only want to add a class or something like that, but it&#8217;s awesome for fine-tuned control when you need a certain page or pages to have individualized content. Super powerful!</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Matt Brett</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1347</link>
		<author>Matt Brett</author>
		<pubDate>Sat, 23 Feb 2008 17:25:13 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1347</guid>
					<description>I find myself using WP's &lt;a href="http://codex.wordpress.org/Conditional_Tags" rel="nofollow"&gt;conditional tags&lt;/a&gt; more and more these days.  They come in super handy for doing things like setting the current state for nav items and displaying unique content depending on the page you're on.

As Laura mentioned, page templates are great when you're making significant changes, but conditional tags do the job when you're changing minor details.

I did some pretty crazy stuff with the &lt;a href="http://graphics.net" rel="nofollow"&gt;Graphics.net redesign&lt;/a&gt;, where I used WP posts for nearly every bit of content on the site, and specified unique content for different pages using conditionals.  Here's how I set the active state of the "blog" tab if you're on the blog page, on a subpage of /blog, viewing an author archive, viewing a category archive, or viewing a post that's in the blog category...

&lt;code&gt;if (is_page('5') &#124;&#124; is_child('5') &#124;&#124; is_author() &#124;&#124; is_category() &#124;&#124; in_category('7') &#38;&#38; is_single()) : echo " id=\"current\""; endif;&lt;/code&gt;

Phew!  For the PHP n00bs, the &lt;code&gt;&#124;&#124;&lt;/code&gt; equals "or", while &lt;code&gt;&#38;&#38;&lt;/code&gt; equals "and" - handy if you need to specify more than one condition... like being a post and in a certain category as I've done here.

Anyway, there's tons you can do with conditionals, and I have a feeling you're going to start using them more frequently.</description>
		<content:encoded><![CDATA[<p>I find myself using WP&#8217;s <a href="http://codex.wordpress.org/Conditional_Tags" rel="nofollow">conditional tags</a> more and more these days.  They come in super handy for doing things like setting the current state for nav items and displaying unique content depending on the page you&#8217;re on.</p>
<p>As Laura mentioned, page templates are great when you&#8217;re making significant changes, but conditional tags do the job when you&#8217;re changing minor details.</p>
<p>I did some pretty crazy stuff with the <a href="http://graphics.net" rel="nofollow">Graphics.net redesign</a>, where I used WP posts for nearly every bit of content on the site, and specified unique content for different pages using conditionals.  Here&#8217;s how I set the active state of the &#8220;blog&#8221; tab if you&#8217;re on the blog page, on a subpage of /blog, viewing an author archive, viewing a category archive, or viewing a post that&#8217;s in the blog category&#8230;</p>
<p><code>if (is_page('5') || is_child('5') || is_author() || is_category() || in_category('7') &amp;&amp; is_single()) : echo " id=\"current\""; endif;</code></p>
<p>Phew!  For the PHP n00bs, the <code>||</code> equals &#8220;or&#8221;, while <code>&amp;&amp;</code> equals &#8220;and&#8221; - handy if you need to specify more than one condition&#8230; like being a post and in a certain category as I&#8217;ve done here.</p>
<p>Anyway, there&#8217;s tons you can do with conditionals, and I have a feeling you&#8217;re going to start using them more frequently.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Si Jobling</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1349</link>
		<author>Si Jobling</author>
		<pubDate>Sat, 23 Feb 2008 19:36:07 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1349</guid>
					<description>I'm a huge advocate of WordPress too - most website requirements I get on quick freelance projects manage to fit around the WordPress platform, if only for the standard CMS system.

I also used a very similar technique on a recent website for some friends running for charity called &lt;a href="http://www.elfrunners.org.uk" rel="nofollow"&gt;ELF Runners&lt;/a&gt; (donations are still welcome!). The main difference for me though was to apply the page slug to the body class so I had an easy handle on all the pages (and was very specific).

Maybe I should create a quick write up like yourself...</description>
		<content:encoded><![CDATA[<p>I&#8217;m a huge advocate of WordPress too - most website requirements I get on quick freelance projects manage to fit around the WordPress platform, if only for the standard CMS system.</p>
<p>I also used a very similar technique on a recent website for some friends running for charity called <a href="http://www.elfrunners.org.uk" rel="nofollow">ELF Runners</a> (donations are still welcome!). The main difference for me though was to apply the page slug to the body class so I had an easy handle on all the pages (and was very specific).</p>
<p>Maybe I should create a quick write up like yourself&#8230;</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Donna</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1350</link>
		<author>Donna</author>
		<pubDate>Sat, 23 Feb 2008 23:19:19 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1350</guid>
					<description>Hi,
Great Post its really helpful.

I'm Donna and I'm new in wordpress and I just want to know in this part of your page &lt;b&gt;"Speaking engagements"&lt;/b&gt; are the content dynamic? I hope you'll answer this and what technique do you use?

Thank Elliot and more power!</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Great Post its really helpful.</p>
<p>I&#8217;m Donna and I&#8217;m new in wordpress and I just want to know in this part of your page <b>&#8220;Speaking engagements&#8221;</b> are the content dynamic? I hope you&#8217;ll answer this and what technique do you use?</p>
<p>Thank Elliot and more power!</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Hamish M</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1351</link>
		<author>Hamish M</author>
		<pubDate>Sun, 24 Feb 2008 00:12:16 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1351</guid>
					<description>Great technique!

Also, like Laura said, Page Templates are another great way to customize your pages. Keep up the good work. :)</description>
		<content:encoded><![CDATA[<p>Great technique!</p>
<p>Also, like Laura said, Page Templates are another great way to customize your pages. Keep up the good work. :)</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Darren Hoyt</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1352</link>
		<author>Darren Hoyt</author>
		<pubDate>Sun, 24 Feb 2008 06:00:26 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1352</guid>
					<description>Thanks for the mention, Elliot (and good luck post-Carsonified, btw!). I like what you did to tweak the code.

&lt;em&gt;Plus the extra code dealt with adding both a class and an ID, as well as checking if the page was an ‘interior’ one or not. I didn’t need anything like this complexity&lt;/em&gt;

Re: that extra code, it's just a product of how I typically design sites -- the homepage has a distinct layout, while all interior pages tend to share a layout, so #home and #interior provide hooks for the CSS to edit things like masthead height, column size, and so on. This provides a ton of control and allows me to recycle classes like ".masthead" according to their context rather than creating bloated new ones like ".home-masthead" and ".interior-masthead". 

Then with the dynamic body class, you get additional granularity when you want to tweak specific elements on some pages and not others (just as you were saying):

body.about-us h2 {
color:red}

body.contact-us h2 {
color:blue
}

Hope that makes sense, I seem to have an easier time coding this stuff than articulating it well ;)

&lt;em&gt;Another way to tackle this is through the use of custom page templates. &lt;/em&gt;

I'd warn against using them too often as it bloats the theme and reduces your ability to make global changes. The various ways of deploying &lt;a href="http://codex.wordpress.org/Conditional_Tags" rel="nofollow"&gt;WP conditionals&lt;/a&gt; ultimately make your templates 'smarter' and less numerous.</description>
		<content:encoded><![CDATA[<p>Thanks for the mention, Elliot (and good luck post-Carsonified, btw!). I like what you did to tweak the code.</p>
<p><em>Plus the extra code dealt with adding both a class and an ID, as well as checking if the page was an ‘interior’ one or not. I didn’t need anything like this complexity</em></p>
<p>Re: that extra code, it&#8217;s just a product of how I typically design sites &#8212; the homepage has a distinct layout, while all interior pages tend to share a layout, so #home and #interior provide hooks for the CSS to edit things like masthead height, column size, and so on. This provides a ton of control and allows me to recycle classes like &#8220;.masthead&#8221; according to their context rather than creating bloated new ones like &#8220;.home-masthead&#8221; and &#8220;.interior-masthead&#8221;. </p>
<p>Then with the dynamic body class, you get additional granularity when you want to tweak specific elements on some pages and not others (just as you were saying):</p>
<p>body.about-us h2 {<br />
color:red}</p>
<p>body.contact-us h2 {<br />
color:blue<br />
}</p>
<p>Hope that makes sense, I seem to have an easier time coding this stuff than articulating it well ;)</p>
<p><em>Another way to tackle this is through the use of custom page templates. </em></p>
<p>I&#8217;d warn against using them too often as it bloats the theme and reduces your ability to make global changes. The various ways of deploying <a href="http://codex.wordpress.org/Conditional_Tags" rel="nofollow">WP conditionals</a> ultimately make your templates &#8217;smarter&#8217; and less numerous.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Steven Clark</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1353</link>
		<author>Steven Clark</author>
		<pubDate>Sun, 24 Feb 2008 09:27:39 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1353</guid>
					<description>I use a very similar piece of code on the Hunter Island Press Inc site - 

http://hunterislandpress.org.au.

The news section (or blog) is a sub-section of the site. So a special template is used on the home page.

So in header.php I simply have a php if else statement that says

if(!is_page()) {
   // then the body = News
} else {
   // then the body id = the_title();
}

So on normal pages on the site the id is for a page but anywhere in the news section (search, categories, single) the id stays News.

Its a handy little way of isolating the news section entirely for a little special treatment - perhaps a subtle colour as an ambient signifier.</description>
		<content:encoded><![CDATA[<p>I use a very similar piece of code on the Hunter Island Press Inc site - </p>
<p><a href="http://hunterislandpress.org.au." rel="nofollow">http://hunterislandpress.org.au.</a></p>
<p>The news section (or blog) is a sub-section of the site. So a special template is used on the home page.</p>
<p>So in header.php I simply have a php if else statement that says</p>
<p>if(!is_page()) {<br />
   // then the body = News<br />
} else {<br />
   // then the body id = the_title();<br />
}</p>
<p>So on normal pages on the site the id is for a page but anywhere in the news section (search, categories, single) the id stays News.</p>
<p>Its a handy little way of isolating the news section entirely for a little special treatment - perhaps a subtle colour as an ambient signifier.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Elliot Jay Stocks</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1354</link>
		<author>Elliot Jay Stocks</author>
		<pubDate>Sun, 24 Feb 2008 15:14:29 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1354</guid>
					<description>Cheers for the comments, guys and gals...

@ Sam Brown: Yep, I'm still using TextMate. I love it!

@ Mark: Thanks for the Symphony link - it looks pretty impressive. Beautifully designed admin section, too! I must admit that so far it doesn't look like it can do anything WP &lt;em&gt;cannot&lt;/em&gt;, but I may well look into this when I get the time (and it'd be a good excuse to get up-to-speed with XSLT).

@ Brian Cobb: Not as far as I know, I'm afraid.

@ Laura &#038; Hamish M: You're right; using custom page templates means lots of flexibility, although I second Darren Hoyt's comment about page templates causing unnecessary theme bloating. For instance (and this isn't best practice at all but just as an off-the-cuff example), you could use the following CSS to hide or display content and just one single page template:

&lt;pre style="padding:10px; overflow:auto"&gt;
body.pageIsNormal div.sidebarOne { display:block }
body.pageIsNormal div.sidebarTwo { display:none }
body.pageIsSpecial div.sidebarOne { display:none }
body.pageIsSpecial div.sidebarTwo { display:block }
&lt;/pre&gt;

@ Matt Brett: Thanks for sharing the tips about conditional comments - this is really useful stuff. In fact I can think of a project I can use that code in straight away! Might IM you later about it...

@ Donna: I'm afraid the 'speaking engagements' links are actually hard-coded. They'll be dynamic in the next version of the site, though, so I'll be sure to do a write-up.

@ Darren Hoyt: Thanks! And yeah, the interior thing makes a lot of sense. I hope you don't think I was criticising your code! :)

@ Steven Clark: I've just been reading &lt;a href="http://stevenclark.com.au/2008/02/24/dynamic-body-id-in-wordpress/" rel="nofollow"&gt;your post on the subject&lt;/a&gt;, and I have to say I think your method is excellent, especially in the way that it applies a dynamic id only to certain pre-specified pages.</description>
		<content:encoded><![CDATA[<p>Cheers for the comments, guys and gals&#8230;</p>
<p>@ Sam Brown: Yep, I&#8217;m still using TextMate. I love it!</p>
<p>@ Mark: Thanks for the Symphony link - it looks pretty impressive. Beautifully designed admin section, too! I must admit that so far it doesn&#8217;t look like it can do anything WP <em>cannot</em>, but I may well look into this when I get the time (and it&#8217;d be a good excuse to get up-to-speed with XSLT).</p>
<p>@ Brian Cobb: Not as far as I know, I&#8217;m afraid.</p>
<p>@ Laura &#038; Hamish M: You&#8217;re right; using custom page templates means lots of flexibility, although I second Darren Hoyt&#8217;s comment about page templates causing unnecessary theme bloating. For instance (and this isn&#8217;t best practice at all but just as an off-the-cuff example), you could use the following CSS to hide or display content and just one single page template:</p>
<pre style="padding:10px; overflow:auto">
body.pageIsNormal div.sidebarOne { display:block }
body.pageIsNormal div.sidebarTwo { display:none }
body.pageIsSpecial div.sidebarOne { display:none }
body.pageIsSpecial div.sidebarTwo { display:block }
</pre>
<p>@ Matt Brett: Thanks for sharing the tips about conditional comments - this is really useful stuff. In fact I can think of a project I can use that code in straight away! Might IM you later about it&#8230;</p>
<p>@ Donna: I&#8217;m afraid the &#8217;speaking engagements&#8217; links are actually hard-coded. They&#8217;ll be dynamic in the next version of the site, though, so I&#8217;ll be sure to do a write-up.</p>
<p>@ Darren Hoyt: Thanks! And yeah, the interior thing makes a lot of sense. I hope you don&#8217;t think I was criticising your code! :)</p>
<p>@ Steven Clark: I&#8217;ve just been reading <a href="http://stevenclark.com.au/2008/02/24/dynamic-body-id-in-wordpress/" rel="nofollow">your post on the subject</a>, and I have to say I think your method is excellent, especially in the way that it applies a dynamic id only to certain pre-specified pages.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Darren Hoyt</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1355</link>
		<author>Darren Hoyt</author>
		<pubDate>Sun, 24 Feb 2008 17:32:11 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1355</guid>
					<description>&lt;em&gt;I hope you don’t think I was criticising your code!&lt;/em&gt;

Not at all - just didn't want anyone confused as to what the sweet hell "interior" was supposed to mean ;) Just one of those naming conventions that's evolved over the years.</description>
		<content:encoded><![CDATA[<p><em>I hope you don’t think I was criticising your code!</em></p>
<p>Not at all - just didn&#8217;t want anyone confused as to what the sweet hell &#8220;interior&#8221; was supposed to mean ;) Just one of those naming conventions that&#8217;s evolved over the years.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Matt Munsey</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1357</link>
		<author>Matt Munsey</author>
		<pubDate>Mon, 25 Feb 2008 03:31:57 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1357</guid>
					<description>I have used a similar technique to apply different headers to a page. I had a flash header for the home page, but I didn't want the flash header to be on ever page. I used very similar code to tell which div the page should use for the header. It really is a wonderful little tool.</description>
		<content:encoded><![CDATA[<p>I have used a similar technique to apply different headers to a page. I had a flash header for the home page, but I didn&#8217;t want the flash header to be on ever page. I used very similar code to tell which div the page should use for the header. It really is a wonderful little tool.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Alan</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1359</link>
		<author>Alan</author>
		<pubDate>Tue, 26 Feb 2008 00:49:25 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1359</guid>
					<description>I want to adapt Wordpress into a real CMS next. Something along these lines would come in handy. I was also thinking to modify this to something like:
&lt;code&gt;
&#60;body id="&#60;?php the_title() ?&#62;"
&lt;/code&gt;
and
&lt;code&gt;
&#60;link rel="stylesheet" href="path/to/theme/&#60;?php the_title() ?&#62;.css" type="text/css" media="screen"&#62;
&lt;/code&gt;
Doing that you could easily add header specific images, optional colors for each page and current page navigation with the same php mod.
&lt;code&gt;
&#60;li&#62;&#60;a href="/about" class="&#60;?php the_title() ?&#62;"&#62;About&#60;/a&#62;&#60;/li&#62;
body#About a:link.About { active state; }
&lt;/code&gt;

Of course a base style sheet is stil there, the page specific ones would just have the necessary  overrides.

I learn more and more about PHP everyday and readin posts like this and experimenting with Wordpress goes along way.</description>
		<content:encoded><![CDATA[<p>I want to adapt Wordpress into a real CMS next. Something along these lines would come in handy. I was also thinking to modify this to something like:<br />
<code><br />
&lt;body id="&lt;?php the_title() ?&gt;"<br />
</code><br />
and<br />
<code><br />
&lt;link rel="stylesheet" href="path/to/theme/&lt;?php the_title() ?&gt;.css" type="text/css" media="screen"&gt;<br />
</code><br />
Doing that you could easily add header specific images, optional colors for each page and current page navigation with the same php mod.<br />
<code><br />
&lt;li&gt;&lt;a href="/about" class="&lt;?php the_title() ?&gt;"&gt;About&lt;/a&gt;&lt;/li&gt;<br />
body#About a:link.About { active state; }<br />
</code></p>
<p>Of course a base style sheet is stil there, the page specific ones would just have the necessary  overrides.</p>
<p>I learn more and more about PHP everyday and readin posts like this and experimenting with Wordpress goes along way.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Josh Stodola</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1360</link>
		<author>Josh Stodola</author>
		<pubDate>Tue, 26 Feb 2008 02:07:51 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1360</guid>
					<description>Elliot,

Your code snippets are unfortunate victims of an IE bug (Firefox and Opera render them correctly, of course).  There is an unnecessary vertical scrollbar, which is distracting.  If you feel so inclined, I have &lt;a href="http://blog.josh420.com/archives/2007/11/fixing-the-ie-overflow-vertical-scrollbar-bug.aspx" rel="nofollow"&gt;a fix for the problem&lt;/a&gt;.

Best regards...</description>
		<content:encoded><![CDATA[<p>Elliot,</p>
<p>Your code snippets are unfortunate victims of an IE bug (Firefox and Opera render them correctly, of course).  There is an unnecessary vertical scrollbar, which is distracting.  If you feel so inclined, I have <a href="http://blog.josh420.com/archives/2007/11/fixing-the-ie-overflow-vertical-scrollbar-bug.aspx" rel="nofollow">a fix for the problem</a>.</p>
<p>Best regards&#8230;</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Jermayn Parker</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1365</link>
		<author>Jermayn Parker</author>
		<pubDate>Wed, 27 Feb 2008 02:02:22 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1365</guid>
					<description>Mmmm great read and some good food for thought.
I have a new website that this will be good for. I had wanted this feature for a previous website but left it alone but not know.

What I love about WordPress is that when you think you know everything, bam comes a new idea/ Plugin/ way of doing things and blows your preconceive ideas out the window!

Please keep these ideas etc coming...</description>
		<content:encoded><![CDATA[<p>Mmmm great read and some good food for thought.<br />
I have a new website that this will be good for. I had wanted this feature for a previous website but left it alone but not know.</p>
<p>What I love about WordPress is that when you think you know everything, bam comes a new idea/ Plugin/ way of doing things and blows your preconceive ideas out the window!</p>
<p>Please keep these ideas etc coming&#8230;</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Will</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1370</link>
		<author>Will</author>
		<pubDate>Sun, 02 Mar 2008 03:15:44 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1370</guid>
					<description>Nice little bit of code. I just dropped it into the header of a project for a new client. I'm taking your "Starkers" theme for a spin as well. I love the dynamic body class idea. Sandbox handles it very well, but it's extremely heavy code-wise. I used it as the basis of my own site and was able to add nifty "placecards" using the dynamic class that change depending on the type of page the reader is on. 

The current project just doesn't need that level of detail, but this code is mighty compact. It'll help a lot.</description>
		<content:encoded><![CDATA[<p>Nice little bit of code. I just dropped it into the header of a project for a new client. I&#8217;m taking your &#8220;Starkers&#8221; theme for a spin as well. I love the dynamic body class idea. Sandbox handles it very well, but it&#8217;s extremely heavy code-wise. I used it as the basis of my own site and was able to add nifty &#8220;placecards&#8221; using the dynamic class that change depending on the type of page the reader is on. </p>
<p>The current project just doesn&#8217;t need that level of detail, but this code is mighty compact. It&#8217;ll help a lot.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Panagiotis</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1404</link>
		<author>Panagiotis</author>
		<pubDate>Sat, 08 Mar 2008 23:19:09 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1404</guid>
					<description>I suggest you try the &lt;a href="http://www.alistercameron.com/2007/01/04/wordpress-plugin-classybody/" rel="nofollow"&gt;ClassyBody plugin.&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>I suggest you try the <a href="http://www.alistercameron.com/2007/01/04/wordpress-plugin-classybody/" rel="nofollow">ClassyBody plugin.</a></p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Austin</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1516</link>
		<author>Austin</author>
		<pubDate>Wed, 26 Mar 2008 01:03:15 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1516</guid>
					<description>Thats pretty cool, I think I am going to mess with that on my next WP project.</description>
		<content:encoded><![CDATA[<p>Thats pretty cool, I think I am going to mess with that on my next WP project.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Sam Hardacre</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1604</link>
		<author>Sam Hardacre</author>
		<pubDate>Tue, 08 Apr 2008 20:25:21 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1604</guid>
					<description>This is great : ) It may just be the thing I've been looking for to pull off the layout for my blog. Cheers Elliot!</description>
		<content:encoded><![CDATA[<p>This is great : ) It may just be the thing I&#8217;ve been looking for to pull off the layout for my blog. Cheers Elliot!</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Matthew Hill</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1610</link>
		<author>Matthew Hill</author>
		<pubDate>Tue, 15 Apr 2008 21:19:30 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1610</guid>
					<description>I'm coming to this one a bit late, but here's another take.

I have a lot of different templates for my site, but the opening CONTENT div is specified in the header.php. To get different classes in there, I set a global variable in my template file and simply echo this in my header.php.

So, in your template at the top, you'll have something like this:
&lt;code&gt;
&#60;?php
global $contentClass;
$contentClass = "wide";
get_header();
?&#62;
&lt;/code&gt;

In your header.php, you set the global variable anywhere in a php code block, but before you need to use it:
&lt;code&gt;
&#60;?php
global $contentClass;
?&#62;
&lt;/code&gt;
Then in your header, after that global variable is called, your HTML block would be something like this:
&lt;code&gt;
&#60;div id="content" class="&#60;?php echo $contentClass;?&#62;"&#62;
&lt;/code&gt;

Works great and means I only need to set the class on templates that need it. Anything else will just leave the class on the content div empty.</description>
		<content:encoded><![CDATA[<p>I&#8217;m coming to this one a bit late, but here&#8217;s another take.</p>
<p>I have a lot of different templates for my site, but the opening CONTENT div is specified in the header.php. To get different classes in there, I set a global variable in my template file and simply echo this in my header.php.</p>
<p>So, in your template at the top, you&#8217;ll have something like this:<br />
<code><br />
&lt;?php<br />
global $contentClass;<br />
$contentClass = "wide";<br />
get_header();<br />
?&gt;<br />
</code></p>
<p>In your header.php, you set the global variable anywhere in a php code block, but before you need to use it:<br />
<code><br />
&lt;?php<br />
global $contentClass;<br />
?&gt;<br />
</code><br />
Then in your header, after that global variable is called, your HTML block would be something like this:<br />
<code><br />
&lt;div id="content" class="&lt;?php echo $contentClass;?&gt;"&gt;<br />
</code></p>
<p>Works great and means I only need to set the class on templates that need it. Anything else will just leave the class on the content div empty.</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Austin</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1611</link>
		<author>Austin</author>
		<pubDate>Tue, 15 Apr 2008 23:31:51 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1611</guid>
					<description>I want to thank you.
I was looking for a way to use conditional tags to change the state in which my head navigation displayed. I am using the tags to change the background state of the image to show the page it is currently on.

Cheers,
Frosty
&lt;a href="http://frostywebdesigns.com" title="Frosty Web Designs" rel="nofollow"&gt;Frosty Web Designs&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>I want to thank you.<br />
I was looking for a way to use conditional tags to change the state in which my head navigation displayed. I am using the tags to change the background state of the image to show the page it is currently on.</p>
<p>Cheers,<br />
Frosty<br />
<a href="http://frostywebdesigns.com" title="Frosty Web Designs" rel="nofollow">Frosty Web Designs</a></p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Shaun</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1619</link>
		<author>Shaun</author>
		<pubDate>Sun, 20 Apr 2008 17:02:55 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1619</guid>
					<description>Thanks for this post! I'd been trying to do exactly the same all day. If only i'd have turned to Google sooner!</description>
		<content:encoded><![CDATA[<p>Thanks for this post! I&#8217;d been trying to do exactly the same all day. If only i&#8217;d have turned to Google sooner!</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Elliot Jay Stocks</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1650</link>
		<author>Elliot Jay Stocks</author>
		<pubDate>Sat, 26 Apr 2008 14:02:51 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1650</guid>
					<description>Glad you're finding this useful, guys. And thanks for posting your own tips too - all very handy!</description>
		<content:encoded><![CDATA[<p>Glad you&#8217;re finding this useful, guys. And thanks for posting your own tips too - all very handy!</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: ikram-zidane</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1712</link>
		<author>ikram-zidane</author>
		<pubDate>Thu, 08 May 2008 15:31:49 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1712</guid>
					<description>isnt there is such thing as 'dynamic menu highlighting' in the wp codex ?</description>
		<content:encoded><![CDATA[<p>isnt there is such thing as &#8216;dynamic menu highlighting&#8217; in the wp codex ?</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Furious Photographers</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1726</link>
		<author>Furious Photographers</author>
		<pubDate>Thu, 15 May 2008 15:31:15 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-1726</guid>
					<description>Awesome ideas!  Thanks for sharing!  I intend to use this for my new wedding photography &lt;a href="http://www.furiousphotographersblog.com" title="wedding photography" rel="nofollow"&gt;blog&lt;/a&gt; that uses WordPress.  I used to use Blogger...not as fun. 

You rock,

Lawrence</description>
		<content:encoded><![CDATA[<p>Awesome ideas!  Thanks for sharing!  I intend to use this for my new wedding photography <a href="http://www.furiousphotographersblog.com" title="wedding photography" rel="nofollow">blog</a> that uses WordPress.  I used to use Blogger&#8230;not as fun. </p>
<p>You rock,</p>
<p>Lawrence</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Karl Bedford</title>
		<link>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-2067</link>
		<author>Karl Bedford</author>
		<pubDate>Wed, 02 Jul 2008 18:14:13 +0000</pubDate>
		<guid>http://elliotjaystocks.com/blog/archive/2008/wordpress-tutorialhow-to-apply-a-dynamic-body-class-or-id/#comment-2067</guid>
					<description>&lt;i&gt;@ Matt Brett:&lt;/i&gt; You don't know how much time you saved me with your comments about &lt;code&gt;&#38;&#38;&lt;/code&gt; and &lt;code&gt;&#124;&#124;&lt;/code&gt; . I didn't know you could &lt;code&gt;in_category('9') &#38;&#38; is_single()&lt;/code&gt;.

Many thanks
Karl</description>
		<content:encoded><![CDATA[<p><i>@ Matt Brett:</i> You don&#8217;t know how much time you saved me with your comments about <code>&amp;&amp;</code> and <code>||</code> . I didn&#8217;t know you could <code>in_category('9') &amp;&amp; is_single()</code>.</p>
<p>Many thanks<br />
Karl</p>
]]></content:encoded>
				</item>
</channel>
</rss>
