<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" 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/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>ThemeShaper</title>
	
	<link>http://themeshaper.com</link>
	<description>Shaping WordPress Themes</description>
	<lastBuildDate>Thu, 15 Oct 2009 01:22:16 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/ThemeShaper" type="application/rss+xml" /><feedburner:emailServiceId>ThemeShaper</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Neutica+: An Advanced Child Theme for the Thematic Theme Framework</title>
		<link>http://feedproxy.google.com/~r/ThemeShaper/~3/DVkhWMrv1dc/</link>
		<comments>http://themeshaper.com/neutica-advanced-child-theme-thematic-theme/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 17:35:28 +0000</pubDate>
		<dc:creator>Ian Stewart</dc:creator>
				<category><![CDATA[Thematic Child Themes]]></category>

		<guid isPermaLink="false">http://themeshaper.com/?p=2190</guid>
		<description><![CDATA[Thematic expert, Allan Cole, has released another beautiful Thematic Child Theme. This time it’s an advanced Child Theme called, Neutica+.]]></description>
			<content:encoded><![CDATA[<p><strong class="caps">Thematic expert</strong>, Allan Cole, has released another beautiful Thematic Child Theme. This time it&#8217;s an advanced Child Theme called, <a href="http://fthrwght.com/neuticaplus/">Neutica+</a>. Behold the enormous&nbsp;screenshot.</p>
<p><a href="http://fthrwght.com/neuticaplus/"><img src="http://themeshaper.com/wp-content/uploads/2009/10/neutica-screenshot.jpg" alt="neutica-screenshot" title="neutica-screenshot" class="alignnone size-full wp-image-2191" /></a></p>
<p><strong>Neutica+&nbsp;Features:</strong></p>
<ul>
<li>A strict grid based design mixed with clean typography heavily influenced by the work of Josef&nbsp;Müller-Brockmann</li>
<li>A theme options page for easy customization of colors, layout, post formating,&nbsp;etc</li>
<li>Optional Featured posts section which pulls random ‚Äústicky‚Äù&nbsp;posts</li>
<li>3 widgetized sidebar&nbsp;areas</li>
<li>5 additional &#038; optional, in-post, ad-spaces for banners &#038;&nbsp;widgets</li>
<li>Crispy clean and valid XHTML Markup with Microformats courtesy the of Thematic theme&nbsp;framework</li>
<li>Valid CSS that has been browser proofed for Firefox, Safari, &#038; most Internet Explorer browsers (including the dreaded&nbsp;IE6!)</li>
</ul>
<p>You absolutely have to check this one out. It just plain deserves to be seen. Go take a look at the <a href="http://fthrwght.com/neuticaplus/">Neutica+ Child Theme for&nbsp;Thematic</a>.</p>
Similar Posts:<ul><li><a href="http://themeshaper.com/collapsing-wordpress-widget-ready-areas-sidebars/" rel="bookmark" title="August 7, 2008">Collapsing WordPress Widget-Ready Areas &#038;&nbsp;Sidebars</a></li>

<li><a href="http://themeshaper.com/wordpress-theme-sidebar-template/" rel="bookmark" title="July 6, 2009">The WordPress Theme Sidebar&nbsp;Template</a></li>

<li><a href="http://themeshaper.com/create-wordpress-themes-huh/" rel="bookmark" title="June 16, 2009">So You Want To Create WordPress Themes,&nbsp;Huh?</a></li>
</ul><!-- Similar Posts took 4.381 ms --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=DVkhWMrv1dc:71EMvPARbw8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=DVkhWMrv1dc:71EMvPARbw8:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=DVkhWMrv1dc:71EMvPARbw8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=DVkhWMrv1dc:71EMvPARbw8:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=DVkhWMrv1dc:71EMvPARbw8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=DVkhWMrv1dc:71EMvPARbw8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=DVkhWMrv1dc:71EMvPARbw8:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=DVkhWMrv1dc:71EMvPARbw8:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ThemeShaper/~4/DVkhWMrv1dc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://themeshaper.com/neutica-advanced-child-theme-thematic-theme/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://themeshaper.com/neutica-advanced-child-theme-thematic-theme/</feedburner:origLink></item>
		<item>
		<title>The Photo Lover Thematic Child Theme</title>
		<link>http://feedproxy.google.com/~r/ThemeShaper/~3/eXcd8E2CCYA/</link>
		<comments>http://themeshaper.com/photo-lover-thematic-child-theme/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 16:00:58 +0000</pubDate>
		<dc:creator>Ian Stewart</dc:creator>
				<category><![CDATA[Thematic Child Themes]]></category>

		<guid isPermaLink="false">http://themeshaper.com/?p=2186</guid>
		<description><![CDATA[Dave Smith of Gite Guru has launched a new Thematic Child Theme called Photo Lover specifically targeting those with a love of photography and imagery.]]></description>
			<content:encoded><![CDATA[<p><strong class="caps">Dave Smith</strong> of <em>Gite Guru</em> has launched a new Thematic Child Theme called <a href="http://giteguru.com/news/photo-lover-theme-release/">Photo Lover</a> specifically targeting those with a love of photography and&nbsp;imagery.</p>
<p><a href="http://giteguru.com/news/photo-lover-theme-release/"><img src="http://themeshaper.com/wp-content/uploads/2009/10/screenshot_580wide.jpg" alt="screenshot_580wide" title="screenshot_580wide" class="alignnone size-full wp-image-2187" /></a></p>
<p>Photo Lover&nbsp;features: </p>
<ul>
<li>Random background image pulled from a &#8216;backgrounds&#8217; folder within the theme&nbsp;folder</li>
<li>Content showing on semi transparency over the background&nbsp;image</li>
<li>A show / hide image function to remove the content layer so that the background image can be seen in all it&#8217;s&nbsp;glory </li>
</ul>
<p>Make sure you check out the <a href="http://giteguru.com/news/photo-lover-theme-release">Photo Lover Theme for&nbsp;Thematic</a>.</p>
Similar Posts:<ul><li><a href="http://themeshaper.com/a-better-spot-for-the-wordpress-meta/" rel="bookmark" title="March 11, 2008">A Better Spot for The WordPress&nbsp;Meta</a></li>

<li><a href="http://themeshaper.com/hide-all-your-links/" rel="bookmark" title="May 17, 2008">Hide all your&nbsp;links</a></li>

<li><a href="http://themeshaper.com/love-thematic-simple-love-theme/" rel="bookmark" title="March 20, 2009">A Little Love for Thematic: The Simple Love&nbsp;Theme</a></li>
</ul><!-- Similar Posts took 4.621 ms --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=eXcd8E2CCYA:-in1zE43taU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=eXcd8E2CCYA:-in1zE43taU:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=eXcd8E2CCYA:-in1zE43taU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=eXcd8E2CCYA:-in1zE43taU:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=eXcd8E2CCYA:-in1zE43taU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=eXcd8E2CCYA:-in1zE43taU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=eXcd8E2CCYA:-in1zE43taU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=eXcd8E2CCYA:-in1zE43taU:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ThemeShaper/~4/eXcd8E2CCYA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://themeshaper.com/photo-lover-thematic-child-theme/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://themeshaper.com/photo-lover-thematic-child-theme/</feedburner:origLink></item>
		<item>
		<title>Can I Make a ‘Premium’ Theme My Own? And Then Release It?</title>
		<link>http://feedproxy.google.com/~r/ThemeShaper/~3/GoAevaCKkjU/</link>
		<comments>http://themeshaper.com/premium-theme-release/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 18:23:11 +0000</pubDate>
		<dc:creator>Ian Stewart</dc:creator>
				<category><![CDATA[Ideas About Design]]></category>

		<guid isPermaLink="false">http://themeshaper.com/?p=2172</guid>
		<description><![CDATA[Can you make a &#8216;Premium&#8217; Theme your own? And then release it? For free? Or for a fee? The answer is simple.&#160;Yes.
That is, if the &#8216;Premium&#8217; WordPress Theme in question—premium meaning you have to pay for it—is licensed under the GPL. The GPL is the GNU General Public License; a document included with a bunch [...]]]></description>
			<content:encoded><![CDATA[<p><strong class="caps">Can you make</strong> a &#8216;Premium&#8217; Theme your own? And then release it? For free? Or for a fee? The answer is simple.&nbsp;<strong>Yes</strong>.</p>
<p>That is, if the &#8216;Premium&#8217; WordPress Theme in question—<em>premium</em> meaning you have to pay for it—is licensed under the GPL. The GPL is the <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>; a document included with a bunch of different open source projects, like WordPress, that covers the terms of the release and makes sure that it always remains <em>open source</em>. Anyway, what does this mean for &#8216;Premium&#8217; Themes, you&nbsp;ask.</p>
<p>It means you can take a &#8216;Premium&#8217; WordPress Theme you bought and do whatever you want with it—except release it again as a &#8216;closed source&#8217; project. The really cool thing? This gives you the freedom to take that project and <em>improve on&nbsp;it</em>.</p>
<p>Here&#8217;s an example. You&#8217;re a designer and you love working with Photoshop. But it doesn&#8217;t have an instant rainbows-and-unicorns button. Adobe won&#8217;t put it in. If Photoshop were an open source project you could take the code and add in the technology to instantly add rainbows and unicorns to every one of your photos—and then give your customized <em>Photoshop [RaU Edition]</em> to <strong>anyone</strong> who wanted it. Presumably, anyone who loved rainbows and unicorns as much as&nbsp;you.</p>
<p>Same thing with GPL WordPress&nbsp;Themes.</p>
<p>But is it right? Not everyone thinks so. Some people have suggested it&#8217;s <em>sleazy</em> (mostly in response to people buying a Theme and immediately turning around to release it for free). What follows is my answer to the question. It&#8217;s something I posted earlier on the <a href="http://www.wptavern.com/forum/themes-templates/586-paying-download-gpl-themes-2.html#post4743">WordPress Tavern forums</a> and here now where everyone reading ThemeShaper can easily find&nbsp;it.</p>
<h2>Ian Stewart&#8217;s 4 Ideas About Modifying Premium Themes and Releasing&nbsp;Them</h2>
<p>1. Redistributing <em>unmodified</em> GPL code over the internet is not sleazy. Redistributing unmodified GPL code is what the GPL is all about—even if the author of that code is charging for it and depending on that&nbsp;income.</p>
<p>2. Redistributing <em>unmodified</em> GPL code over the internet is pointless and stupid. If you&#8217;re doing it as a matter of free open source principles, sure, I could see that—but you&#8217;re muddying up the web. It doesn&#8217;t add any value to the code and unless you plan on keeping up with updates to that code you&#8217;re actually doing everyone who sees that redistributed code a huge disservice. Way to&nbsp;go.</p>
<p>3. I say &#8220;everyone who sees that redistributed code&#8221; because that will be a small amount of people. A small amount of people who will be rightfully wary of downloading that code. The vast majority of people will choose to download that code from the original author. Anyone want to start downloading WordPress from &#8220;www.crazywpdownloadsite.com&#8221;? I thought so. Remember that &#8220;trust&#8221; and &#8220;authority&#8221; are huge things on the web. People selling GPL WordPress Themes: stop worrying about&nbsp;this.</p>
<p>4. Now that we know that people redistributing <em>unmodified</em> GPL WordPress Themes over the internet are stupid we need to recognize how awesome it is that people can <strong>modify</strong> GPL WordPress Themes and redistribute them online. Theme-sellers: this is how you got started selling themes. Every single one of you. Remember when you were nervously trying to lock up the code for your first theme options pages behind a restrictive license? The code that you essentially copy-pasted from the same 2 online tutorials I and countless others did? I&#8217;m looking at all of you. Anyway, where would you be if that code wasn&#8217;t given to you in the first place? Where would you be if you didn&#8217;t fork the Default Theme? Or Sandbox? Or Classic Theme? Where would you be if Matt didn&#8217;t fork b2? Don&#8217;t worry about people forking your code. The freedom to redistribute modified code is incredibly awesome and, no exaggeration, is quite literally making the world a better&nbsp;place.</p>
<h2>What&nbsp;Now?</h2>
<p>You can find a whole whack of people releasing their Premium Themes under the GPL License on the official <a href="http://wordpress.org/extend/themes/commercial/">WordPress Commercial Themes Directory</a>. You can find all my commercial Child Themes for Thematic in the <a href="http://themeshaper.com/theme-store/">ThemeShaper Thematic Theme&nbsp;Store</a>.</p>
<p>Anyone ready to start making WordPress Themes&nbsp;<em>awesome-er?</em></p>
Similar Posts:<ul><li><a href="http://themeshaper.com/the-ethics-of-premium-wordpress-themes/" rel="bookmark" title="September 8, 2008">The Ethics of WordPress Themes at a&nbsp;Premium</a></li>

<li><a href="http://themeshaper.com/when-premium-wordpress-themes-open-source-ethics-collide/" rel="bookmark" title="September 6, 2008">When Premium WordPress Themes &#038; Open Source Ethics&nbsp;Collide</a></li>

<li><a href="http://themeshaper.com/join-thematic-project/" rel="bookmark" title="December 30, 2008">Join The Thematic&nbsp;Project</a></li>
</ul><!-- Similar Posts took 3.580 ms --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=GoAevaCKkjU:AbT5NnNSFhI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=GoAevaCKkjU:AbT5NnNSFhI:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=GoAevaCKkjU:AbT5NnNSFhI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=GoAevaCKkjU:AbT5NnNSFhI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=GoAevaCKkjU:AbT5NnNSFhI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=GoAevaCKkjU:AbT5NnNSFhI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=GoAevaCKkjU:AbT5NnNSFhI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=GoAevaCKkjU:AbT5NnNSFhI:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ThemeShaper/~4/GoAevaCKkjU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://themeshaper.com/premium-theme-release/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		<feedburner:origLink>http://themeshaper.com/premium-theme-release/</feedburner:origLink></item>
		<item>
		<title>40+ Thematic Resources, Tutorials and Links</title>
		<link>http://feedproxy.google.com/~r/ThemeShaper/~3/PEKlLmzmIrY/</link>
		<comments>http://themeshaper.com/40-thematic-resources-tutorials-links/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 14:54:38 +0000</pubDate>
		<dc:creator>Ian Stewart</dc:creator>
				<category><![CDATA[Theme Tips]]></category>

		<guid isPermaLink="false">http://themeshaper.com/?p=2169</guid>
		<description><![CDATA[The post Build WordPress Sites Fast With the Thematic Theme Framework by Es Developed is a great resource for anyone wanting to get started with the Thematic Theme. It lists over 40 resources and tutorials that&#8217;ll get you where you want to be with rapid WordPress Theme&#160;development.
And there&#8217;s some great explanation behind why you&#8217;d want [...]]]></description>
			<content:encoded><![CDATA[<p>The post <a href="http://esdev.net/build-wordpress-sites-fast-with-the-thematic-theme-framework/">Build WordPress Sites Fast With the Thematic Theme Framework</a> by <em>Es Developed</em> is a great resource for anyone wanting to get started with the <a href="http://themeshaper.com/thematic/">Thematic Theme</a>. It lists over 40 resources and tutorials that&#8217;ll get you where you want to be with rapid WordPress Theme&nbsp;development.</p>
<p>And there&#8217;s some great explanation behind why you&#8217;d want to use the Thematic Theme. Under the heading <em>Don&#8217;t Touch That&nbsp;Theme</em>:</p>
<blockquote><p>To create your theme, you don’t actually edit any of Thematic’s theme files. Instead, you make changes using a separate child&nbsp;theme.</p>
<p>It’s really powerful since you’re not actually touching any part of Thematic. You just get a nice starting place, without worries about future Thematic updates overwriting your code&nbsp;edits.</p>
<p>You don’t have to rewrite a bunch of code all over again–you’re just adding the bits that you want to be different. This works very much like the custom styles on WordPress.com hosted&nbsp;blogs.</p></blockquote>
<p>Make sure you check out <a href="http://esdev.net/build-wordpress-sites-fast-with-the-thematic-theme-framework/">Build WordPress Sites Fast With the Thematic Theme&nbsp;Framework</a>.</p>
Similar Posts:<ul><li><a href="http://themeshaper.com/wordpress-domain-parking-theme/" rel="bookmark" title="January 23, 2008">LaunchPad, The WordPress Domain Parking&nbsp;Theme</a></li>

<li><a href="http://themeshaper.com/matt-mullenweg-joseph-scott-wordpress-themes-directory/" rel="bookmark" title="August 13, 2008">Matt Mullenweg &#038; Joseph Scott Discuss The WordPress Themes&nbsp;Directory</a></li>

<li><a href="http://themeshaper.com/join-thematic-project/" rel="bookmark" title="December 30, 2008">Join The Thematic&nbsp;Project</a></li>
</ul><!-- Similar Posts took 3.293 ms --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=PEKlLmzmIrY:CMzT4XAfbNY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=PEKlLmzmIrY:CMzT4XAfbNY:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=PEKlLmzmIrY:CMzT4XAfbNY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=PEKlLmzmIrY:CMzT4XAfbNY:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=PEKlLmzmIrY:CMzT4XAfbNY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=PEKlLmzmIrY:CMzT4XAfbNY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=PEKlLmzmIrY:CMzT4XAfbNY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=PEKlLmzmIrY:CMzT4XAfbNY:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ThemeShaper/~4/PEKlLmzmIrY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://themeshaper.com/40-thematic-resources-tutorials-links/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://themeshaper.com/40-thematic-resources-tutorials-links/</feedburner:origLink></item>
		<item>
		<title>Get The Thematic Feature Site Theme</title>
		<link>http://feedproxy.google.com/~r/ThemeShaper/~3/EHjoPdT5J-s/</link>
		<comments>http://themeshaper.com/thematic-feature-site-theme/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 02:15:34 +0000</pubDate>
		<dc:creator>Ian Stewart</dc:creator>
				<category><![CDATA[Thematic Child Themes]]></category>

		<guid isPermaLink="false">http://themeshaper.com/?p=2158</guid>
		<description><![CDATA[Want to get the Thematic Child Theme I used to build the last 2 versions of ThemeShaper? Well now you can! I call it the Thematic Feature Site Theme and—just like the Power Blog Theme—it&#8217;s another entry in the Thematic Development&#160;Series.

Just like Power Blog it requires a little bit of code-editing but it&#8217;s an awesome [...]]]></description>
			<content:encoded><![CDATA[<p><strong class="caps">Want to get the Thematic Child Theme</strong> I used to build the last 2 versions of ThemeShaper? Well now you can! I call it the <a href="http://themeshaper.com/thematic-feature-site/">Thematic Feature Site Theme</a> and—just like the <em>Power Blog Theme</em>—it&#8217;s another entry in the Thematic Development&nbsp;Series.</p>
<p><a href="http://themeshaper.com/thematic-feature-site/"><img src="http://themeshaper.com/wp-content/uploads/2009/08/feature-site.jpg" alt="feature-site" title="feature-site" class="alignnone size-full wp-image-2140" /></a></p>
<p>Just like <em>Power Blog</em> it requires a little bit of code-editing but it&#8217;s an <strong>awesome</strong> starting point. I know because I use it myself. I think you&#8217;re going to want to use it&nbsp;too. </p>
<p>Read the big write-up, check out the demo and go get the <a href="http://themeshaper.com/thematic-feature-site/">Thematic Feature Site&nbsp;Theme</a>.</p>
Similar Posts:<ul><li><a href="http://themeshaper.com/custom-page-template-redesign-blog/" rel="bookmark" title="February 2, 2009">How I Used A Custom Page Template To Redesign My Blog The Smart&nbsp;Way</a></li>

<li><a href="http://themeshaper.com/use-wordpress-as-cms-travailler-theme/" rel="bookmark" title="July 21, 2008">Use WordPress As a CMS With The Travailler&nbsp;Theme</a></li>

<li><a href="http://themeshaper.com/power-thematic-power-blog-theme/" rel="bookmark" title="March 26, 2009">Power Up Thematic With The Power Blog&nbsp;Theme</a></li>
</ul><!-- Similar Posts took 3.228 ms --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=EHjoPdT5J-s:I_X_zZAlfZM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=EHjoPdT5J-s:I_X_zZAlfZM:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=EHjoPdT5J-s:I_X_zZAlfZM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=EHjoPdT5J-s:I_X_zZAlfZM:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=EHjoPdT5J-s:I_X_zZAlfZM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=EHjoPdT5J-s:I_X_zZAlfZM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=EHjoPdT5J-s:I_X_zZAlfZM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=EHjoPdT5J-s:I_X_zZAlfZM:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ThemeShaper/~4/EHjoPdT5J-s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://themeshaper.com/thematic-feature-site-theme/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://themeshaper.com/thematic-feature-site-theme/</feedburner:origLink></item>
		<item>
		<title>Early Morning Thematic Child Theme</title>
		<link>http://feedproxy.google.com/~r/ThemeShaper/~3/41CjI5RNAgM/</link>
		<comments>http://themeshaper.com/early-morning-thematic-child-theme/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 19:06:54 +0000</pubDate>
		<dc:creator>Ian Stewart</dc:creator>
				<category><![CDATA[Thematic Child Themes]]></category>

		<guid isPermaLink="false">http://themeshaper.com/?p=2130</guid>
		<description><![CDATA[Cristi Antohe has—yet again—released a beautiful and incredibly usable Thematic Child Theme, Early&#160;Morning.

It’s light, elegant and pleasantly surprising. This theme is all about blogging. It doesn&#8217;t scream at you, instead it takes a step back and lets readers&#160;read.
It also has some nice features out of the&#160;box:

You can upload your own&#160;logo
It comes with it’s own custom [...]]]></description>
			<content:encoded><![CDATA[<p>Cristi Antohe has—yet again—released a beautiful and <em>incredibly usable</em> Thematic Child Theme, <a href="http://www.cozmoslabs.com/2009/07/20/early-morning-child-theme/">Early&nbsp;Morning</a>.</p>
<p><a href="http://www.cozmoslabs.com/2009/07/20/early-morning-child-theme/"><img src="http://themeshaper.com/wp-content/uploads/2009/08/thumb_580.jpg" alt="thumb_580" title="thumb_580" class="alignnone size-full wp-image-2131" /></a></p>
<p>It’s light, elegant and pleasantly surprising. <em>This theme</em> is all about blogging. It doesn&#8217;t scream at you, instead it takes a step back and lets readers&nbsp;read.</p>
<p>It also has some nice features out of the&nbsp;box:</p>
<ul>
<li>You can upload your own&nbsp;logo</li>
<li>It comes with it’s own custom designed Twitter widget, so your visitors can see what you’re doing from your&nbsp;blog</li>
<li>It comes with 5 background options that you can select from the Early Morning Theme Options (Green, Turquoise, Brick Red, Gray and&nbsp;Black)</li>
</ul>
Similar Posts:<ul><li><a href="http://themeshaper.com/street-thematic-child-theme-cozmoslabs/" rel="bookmark" title="June 16, 2009">Street: A Thematic Child Theme by&nbsp;CozmosLabs</a></li>

<li><a href="http://themeshaper.com/commune-thematic-magazine-theme/" rel="bookmark" title="April 7, 2009">Commune: A Thematic Magazine&nbsp;Theme</a></li>

<li><a href="http://themeshaper.com/hide-all-your-links/" rel="bookmark" title="May 17, 2008">Hide all your&nbsp;links</a></li>
</ul><!-- Similar Posts took 3.223 ms --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=41CjI5RNAgM:KLdeZw9eDkc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=41CjI5RNAgM:KLdeZw9eDkc:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=41CjI5RNAgM:KLdeZw9eDkc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=41CjI5RNAgM:KLdeZw9eDkc:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=41CjI5RNAgM:KLdeZw9eDkc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=41CjI5RNAgM:KLdeZw9eDkc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=41CjI5RNAgM:KLdeZw9eDkc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=41CjI5RNAgM:KLdeZw9eDkc:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ThemeShaper/~4/41CjI5RNAgM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://themeshaper.com/early-morning-thematic-child-theme/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://themeshaper.com/early-morning-thematic-child-theme/</feedburner:origLink></item>
		<item>
		<title>SimpleCart (js) a free WP E-Commerce &amp; Thematic Child Theme</title>
		<link>http://feedproxy.google.com/~r/ThemeShaper/~3/5addxFjdAXs/</link>
		<comments>http://themeshaper.com/simplecart-js-free-wp-ecommerce-thematic-child-theme/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 18:59:34 +0000</pubDate>
		<dc:creator>Ian Stewart</dc:creator>
				<category><![CDATA[Thematic Child Themes]]></category>

		<guid isPermaLink="false">http://themeshaper.com/?p=2127</guid>
		<description><![CDATA[Want a free Thematic Child Theme &#8216;specially designed to work with the awesome WP E-Commerce Plugin? You can start with the brilliant SimpleCart (js) Theme by Chris&#160;Wallace.

Similar Posts:The Gallery Theme for Thematic by Chris&#160;Wallace

Instinct &#038; The Thematic Theme&#160;Framework

Get Thematic Version&#160;0.9.5
]]></description>
			<content:encoded><![CDATA[<p>Want a free Thematic Child Theme &#8216;specially designed to work with the awesome WP E-Commerce Plugin? You can start with the brilliant <a href="http://www.chris-wallace.com/2009/07/17/simplecartjs-a-free-wp-e-commerce-thematic-child-theme/">SimpleCart (js) Theme</a> by Chris&nbsp;Wallace.</p>
<p><a href="http://www.chris-wallace.com/2009/07/17/simplecartjs-a-free-wp-e-commerce-thematic-child-theme/"><img src="http://themeshaper.com/wp-content/uploads/2009/08/simplecart-560x396.png" alt="simplecart-560x396" title="simplecart-560x396" class="alignnone size-full wp-image-2128" /></a></p>
Similar Posts:<ul><li><a href="http://themeshaper.com/gallery-theme-thematic/" rel="bookmark" title="May 4, 2009">The Gallery Theme for Thematic by Chris&nbsp;Wallace</a></li>

<li><a href="http://themeshaper.com/instinct-thematic-theme-framework/" rel="bookmark" title="September 25, 2008">Instinct &#038; The Thematic Theme&nbsp;Framework</a></li>

<li><a href="http://themeshaper.com/thematic-version-095/" rel="bookmark" title="June 1, 2009">Get Thematic Version&nbsp;0.9.5</a></li>
</ul><!-- Similar Posts took 3.194 ms --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=5addxFjdAXs:jNzZGqO9roE:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=5addxFjdAXs:jNzZGqO9roE:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=5addxFjdAXs:jNzZGqO9roE:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=5addxFjdAXs:jNzZGqO9roE:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=5addxFjdAXs:jNzZGqO9roE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=5addxFjdAXs:jNzZGqO9roE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=5addxFjdAXs:jNzZGqO9roE:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=5addxFjdAXs:jNzZGqO9roE:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ThemeShaper/~4/5addxFjdAXs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://themeshaper.com/simplecart-js-free-wp-ecommerce-thematic-child-theme/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://themeshaper.com/simplecart-js-free-wp-ecommerce-thematic-child-theme/</feedburner:origLink></item>
		<item>
		<title>How To Reset &amp; Rebuild WordPress Theme CSS &amp; Define Your Layouts</title>
		<link>http://feedproxy.google.com/~r/ThemeShaper/~3/22BxLom80Tk/</link>
		<comments>http://themeshaper.com/reset-rebuild-wordpress-theme-css-define-layouts/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 11:00:35 +0000</pubDate>
		<dc:creator>Ian Stewart</dc:creator>
				<category><![CDATA[Popular]]></category>
		<category><![CDATA[Theme Tips]]></category>

		<guid isPermaLink="false">http://themeshaper.com/?p=1976</guid>
		<description><![CDATA[CSS can be tricky. It can also be incredibly easy. I had a lot of help getting my head wrapped around CSS when I was first starting out and I take great pleasure in helping others the same way I was first helped: with solid code examples to learn&#160;from.
Here we’re going to layout a WordPress [...]]]></description>
			<content:encoded><![CDATA[<p><strong class="caps">CSS can be tricky</strong>. It can also be incredibly easy. I had a lot of help getting my head wrapped around CSS when I was first starting out and I take great pleasure in helping others the same way I was first helped: with solid code examples to learn&nbsp;from.</p>
<p>Here we’re going to layout a WordPress Theme CSS development arsenal for&nbsp;you:</p>
<ul>
<li>A stylesheet that resets default CSS across all web browsers and makes a sane standard we can work&nbsp;from</li>
<li>Another stylesheet that rebuilds our typographical foundations in a smart&nbsp;way</li>
<li>A stylesheet just for WordPress classes (keeping the first two pure so we can use them for non-WordPress&nbsp;projects)</li>
<li>A series of 6 fluid stylesheets that will create ALL the common blog and website layouts you expect—and each one ready to adapt into a fixed width&nbsp;layout.</li>
</ul>
<p>All the code we&#8217;ll talk about is open-source, under the GPL, and browse-able at the <a href="http://code.google.com/p/your-wordpress-theme/source/browse/#svn/trunk/styles">Your Theme Project Page</a>. View the raw source for any one of these files and copy-paste at your&nbsp;leisure.</p>
<p>First things first, make a &#8220;style&#8221; directory in your Theme folder. That&#8217;s where we&#8217;ll be putting everything. Your CSS quiver, as it were. Ready to hit the&nbsp;target?</p>
<h2>Reset&nbsp;CSS</h2>
<p>Our Reset CSS is adapted from <a href="http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/">Eric Meyer’s famous Reset CSS</a> with some minor, minor changes. Basically what it does is take all the typographical defaults of every browser and … obliterates them. You’re left with a squashy, gray&nbsp;mess.</p>
<p>It’s&nbsp;<strong>beautiful</strong>.</p>
<p>What this does is equalize the rendering of every browser, leaving you free to ignore countless individual quirks particular to each&nbsp;one.</p>
<p>Using it is simple. Add the following lines to your <code>style.css</code>, at the very top, immediately after the initial comments&nbsp;section.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p19767"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1976code7"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* Reset default browser styles */</span>
<span style="color: #a1a100;">@import url('styles/reset.css');</span></pre></td></tr></table></div>

<p>Reload, your page and check it what <a href="http://your-wordpress-theme.googlecode.com/svn/trunk/styles/reset.css"><code>reset.css</code></a> does in multiple browsers (if you can). It’s wonderfully gross, isn’t&nbsp;it?</p>
<h2>Rebuild&nbsp;CSS</h2>
<p>Our Rebuild CSS is my own personal invention adapted from an early version of the Blueprint CSS typography stylesheet and refined in the <a href="http://themeshaper.com/thematic/">Thematic Project</a>. What it does is swing back some vertical rhythm in our pages, but in a really smart&nbsp;way.</p>
<p>What I’ve tried to do with this iteration of my typography-rebuild CSS is combine the best of both worlds for web typography: using Pixels for font height, with relative line-height for the main declaration on the body element, and Ems for all subsequent vertical margins (like for paragraphs and&nbsp;lists).</p>
<p>What does this mean? It’s really easy to set your font height later—without doing any math work—and have all of your typographical elements follow suit with an appropriate vertical rhythm (the vertical space between type elements like paragraphs and&nbsp;lists). </p>
<p>Using <a href="http://your-wordpress-theme.googlecode.com/svn/trunk/styles/rebuild.css"><code>rebuild.css</code></a> is also really easy. Just add the following lines immediately after your <code>reset.css</code>&nbsp;import.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p19768"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1976code8"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* Rebuild default browser styles */</span>
<span style="color: #a1a100;">@import url('styles/rebuild.css');</span></pre></td></tr></table></div>

<h2>The Basic WordPress&nbsp;Styles</h2>
<p>There are some elements in WordPress that you&#8217;re just going to have to style every time. What I&#8217;ve done is taken those styles and put them in there own little corner called&nbsp;<code>wp.css</code>.</p>
<p>Right now, what we&#8217;ve got in there are styles for floating all the images—including handling captions and image galleries. And! preset styles for simple pull-quotes. All you need to do is add a class of left or right to the blockquote tag and you&#8217;re ready to&nbsp;roll.</p>
<p>Can you guess how we&#8217;re going to use&nbsp;<a href="http://your-wordpress-theme.googlecode.com/svn/trunk/styles/wp.css"><code>wp.css</code></a>?</p>

<div class="wp_codebox"><table width="100%" ><tr id="p19769"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1976code9"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* Basic WordPress Styles */</span>
<span style="color: #a1a100;">@import url('styles/wp.css');</span></pre></td></tr></table></div>

<h2>All The Layouts You’ll Ever&nbsp;Need</h2>
<p>For your new theme, I’ve taken the rock-solid, indestructible layouts that shipped with the Sandbox Theme and adapted them for your new HTML structure. <a href="http://your-wordpress-theme.googlecode.com/svn/trunk/styles/">There are 6 in total</a>. Each is a fluid layout (that stretches to fill the width of your browser window) but each one is easily adaptable to a fixed width&nbsp;layout.</p>
<p>Using anyone of these layouts is simple. Immediately after your basic WordPress styles import, import one of these layouts. Here’s how to import the 3 column layout, with the content in the&nbsp;center.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p197610"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1976code10"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* Import a basic layout */</span>
<span style="color: #a1a100;">@import url('styles/3c-b.css');</span></pre></td></tr></table></div>

<p>The simplest method of turning any one of these layouts into a fixed-width layout is to add a width and centering margin to the #wrapper&nbsp;div.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p197611"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p1976code11"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#wrapper</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> 0 <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">960px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<h3>Bonus: Styling The&nbsp;Menu</h3>
<p>If you&#8217;ve never taken an unordered list (that&#8217;s the smart markup generated by <a href="http://codex.wordpress.org/Template_Tags/wp_page_menu"><code>wp_page_menu</code></a>) and styled it to look like a menu before it can seem kinda weird. As a bonus, here&#8217;s the CSS I use when I start out creating menus for WordPress&nbsp;Themes.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p197612"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code" id="p1976code12"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#access</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> 0 0 <span style="color: #933;">1.5em</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.skip-link</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
        <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">-9000px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.menu</span> ul <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.menu</span> ul ul <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.menu</span> li <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.menu</span> a <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>It&#8217;s pretty simple but it&#8217;ll put you on sure footing. Good&nbsp;luck!</p>
<h2>How To Create a WordPress&nbsp;Theme</h2>
<p>This post concludes the <a href="http://themeshaper.com/wordpress-themes-templates-tutorial/">WordPress Themes Tutorial series</a> that shows you how to create a powerful WordPress Theme from scratch. Read it from the beginning and code yourself up something&nbsp;awesome.</p>
<ol>
<li><a href="http://themeshaper.com/wordpress-themes-templates-tutorial/">WordPress Theme Tutorial&nbsp;Introduction</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-development-tools-tutorial/">Theme Development&nbsp;Tools</a></li>
<li><a href="http://themeshaper.com/creating-wordpress-theme-html-structure-tutorial/">Creating a Theme HTML&nbsp;Structure</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-template-directory-structure-tutorial/">Template and Directory&nbsp;Structure</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-header-template-tutorial/">The Header&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-index-template-tutorial/">The Index&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-single-post-post-attachment-404-templates-tutorial/">The Single Post, Post Attachment, &#038; 404&nbsp;Templates</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-comments-template-tutorial/">The Comments&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-search-page-template-tutorial/">The Search Template &#038; The Page&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/archive-author-category-tags-template/">The Archive, Author, Category &#038; Tags&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-sidebar-template/">The Sidebar&nbsp;Template</a></li>
<li>Reset-Rebuild Theme CSS &#038; Define Your&nbsp;Layouts</li>
</ol>
<p>If you have any suggestions for posts that will fit in this series or complement what we&#8217;ve done so far I&#8217;d be glad to hear them. Let me know in the&nbsp;comments.</p>
Similar Posts:<ul><li><a href="http://themeshaper.com/thematic-07/" rel="bookmark" title="October 6, 2008">What&#8217;s new in Thematic&nbsp;0.7</a></li>

<li><a href="http://themeshaper.com/modular-css-wordpress-child-themes/" rel="bookmark" title="April 30, 2009">Modular CSS in WordPress Child&nbsp;Themes</a></li>

<li><a href="http://themeshaper.com/wordpress-theme-development-tools-tutorial/" rel="bookmark" title="June 23, 2009">WordPress Theme Development&nbsp;Tools</a></li>
</ul><!-- Similar Posts took 4.133 ms --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=22BxLom80Tk:ikRcB4IerdQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=22BxLom80Tk:ikRcB4IerdQ:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=22BxLom80Tk:ikRcB4IerdQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=22BxLom80Tk:ikRcB4IerdQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=22BxLom80Tk:ikRcB4IerdQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=22BxLom80Tk:ikRcB4IerdQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=22BxLom80Tk:ikRcB4IerdQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=22BxLom80Tk:ikRcB4IerdQ:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ThemeShaper/~4/22BxLom80Tk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://themeshaper.com/reset-rebuild-wordpress-theme-css-define-layouts/feed/</wfw:commentRss>
		<slash:comments>48</slash:comments>
		<feedburner:origLink>http://themeshaper.com/reset-rebuild-wordpress-theme-css-define-layouts/</feedburner:origLink></item>
		<item>
		<title>The WordPress Theme Sidebar Template</title>
		<link>http://feedproxy.google.com/~r/ThemeShaper/~3/Kp1J-PPmaG8/</link>
		<comments>http://themeshaper.com/wordpress-theme-sidebar-template/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 11:00:11 +0000</pubDate>
		<dc:creator>Ian Stewart</dc:creator>
				<category><![CDATA[Theme Tips]]></category>

		<guid isPermaLink="false">http://themeshaper.com/?p=1966</guid>
		<description><![CDATA[I know you’ve been waiting patiently for this one. Everybody loves the Sidebar Template. But we’re going to do ours a little differently than everyone&#160;else.
Ours is going to be&#160;better.
Custom Sidebar&#160;Functions
First things first. With a WordPress Sidebar Template, we need to make sure it’s widgetized. Ours is going to have two widget areas. That way we [...]]]></description>
			<content:encoded><![CDATA[<p><strong class="caps">I know</strong> you’ve been waiting patiently for this one. Everybody loves the Sidebar Template. But we’re going to do ours a little differently than everyone&nbsp;else.</p>
<p>Ours is going to be&nbsp;better.</p>
<h2>Custom Sidebar&nbsp;Functions</h2>
<p>First things first. With a WordPress Sidebar Template, we need to make sure it’s widgetized. Ours is going to have two widget areas. That way we can re-use this code for 2-column or 3-column themes (on a 2-column theme the sidebars are stacked, one on top of the&nbsp;other).</p>
<p>This is pretty straightforward. In our <code>functions.php</code> file we’re going to register our widget areas with the following&nbsp;code.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p196617"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code" id="p1966code17"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Register widgetized areas</span>
<span style="color: #000000; font-weight: bold;">function</span> theme_widgets_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Area 1</span>
	register_sidebar<span style="color: #009900;">&#40;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a> <span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Primary Widget Area'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'primary_widget_area'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'before_widget'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;li id=&quot;%1$s&quot; class=&quot;widget-container %2$s&quot;&gt;'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'after_widget'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;&lt;/li&gt;&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'before_title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;h3 class=&quot;widget-title&quot;&gt;'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'after_title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;/h3&gt;'</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Area 2</span>
	register_sidebar<span style="color: #009900;">&#40;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a> <span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Secondary Widget Area'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'secondary_widget_area'</span><span style="color: #339933;">,</span> 
	<span style="color: #0000ff;">'before_widget'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;li id=&quot;%1$s&quot; class=&quot;widget-container %2$s&quot;&gt;'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'after_widget'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;&lt;/li&gt;&quot;</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'before_title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;h3 class=&quot;widget-title&quot;&gt;'</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'after_title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;/h3&gt;'</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// end theme_widgets_init</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'theme_widgets_init'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Now we’ve got two widget areas: <em>Primary</em> Widget Area and <em>Secondary</em> Widget Area. There’s no point naming them Primary Sidebar or Secondary Sidebar. In some layouts they might not even be sidebars—but they’ll always be widget&nbsp;areas.</p>
<p>Now, still in <code>functions.php</code> we’re going to add two more super-cool custom code&nbsp;snippets.</p>
<p>Firstly, we’re going to pre-set our default widgets: The Search, Pages, Categories, Archives, Links and Meta Widgets. We won’t be coding them in manually to <code>sidebar.php</code>. We’ll be telling WordPress to add them to our dynamic widget area in the settings (thank <a href="http://ptahdunbar.com/wordpress/droppin-knowledge-on-wordpress-how-to-preset-widgets-to-widget-areas/">Ptah Dunbar</a> for&nbsp;this).</p>

<div class="wp_codebox"><table width="100%" ><tr id="p196618"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p1966code18"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$preset_widgets</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a> <span style="color: #009900;">&#40;</span>
	<span style="color: #0000ff;">'primary_widget_area'</span>  <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'search'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'pages'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'categories'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'archives'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #0000ff;">'secondary_widget_area'</span>  <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'links'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'meta'</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'activated'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	update_option<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'sidebars_widgets'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$preset_widgets</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">// update_option( 'sidebars_widgets', NULL );</span></pre></td></tr></table></div>

<p>Now, in our Primary Widget Area (<code>primary_widget_area</code>) we&#8217;ve got the Search Widget, the Pages Widget, the Categories Widget, and the Archives Widget. The Secondary Widget Area (<code>secondary_widget_area</code>) has the Links and Meta Widgets. They&#8217;re all loaded up there in our WordPress options, ready and&nbsp;waiting.</p>
<p>Did you see <code>// update_option( 'sidebars_widgets', NULL );</code> in the last line? Uncomment that line if you need to reset your widgets for any reason. As I&#8217;m sure you can guess, <code>NULL</code> means <em>no&nbsp;widgets</em>.</p>
<p>Now secondly, we’re going to create a new conditional that will check to see if there are any widgets in a given widget area. This will be incredibly useful (with props to <a href="http://blog.kaizeku.com/">Chaos Kaizer</a>) when we code up our Sidebar&nbsp;Template.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p196619"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p1966code19"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Check for static widgets in widget-ready areas</span>
<span style="color: #000000; font-weight: bold;">function</span> is_sidebar_active<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$index</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_registered_sidebars</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000088;">$widgetcolums</span> <span style="color: #339933;">=</span> wp_get_sidebars_widgets<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$widgetcolums</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$index</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// end is_sidebar_active</span></pre></td></tr></table></div>

<p>Now we need to put these custom code snippets to&nbsp;work.</p>
<h2>Coding The Sidebar&nbsp;Template</h2>
<p>With our dynamic widget areas registered and pre-set widgets, our Sidebar Template is going to be one of the simplest templates you’ll ever see. But remember, we’re also going to want to wrap our sidebars in an IF statement using our new conditional&nbsp;is_sidebar_active().</p>
<p>Here’s what it’ll look&nbsp;like:</p>

<div class="wp_codebox"><table width="100%" ><tr id="p196620"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p1966code20"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> is_sidebar_active<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'primary_widget_area'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
		<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;primary&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;widget-area&quot;</span><span style="color: #339933;">&gt;</span>
			<span style="color: #339933;">&lt;</span>ul <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;xoxo&quot;</span><span style="color: #339933;">&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;?php</span> dynamic_sidebar<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'primary_widget_area'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
			<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
		<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#primary .widget-area --&gt;
</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>		
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> is_sidebar_active<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'secondary_widget_area'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
		<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;secondary&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;widget-area&quot;</span><span style="color: #339933;">&gt;</span>
			<span style="color: #339933;">&lt;</span>ul <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;xoxo&quot;</span><span style="color: #339933;">&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;?php</span> dynamic_sidebar<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'secondary_widget_area'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
			<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
		<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#secondary .widget-area --&gt;
</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Now if you go into the widget admin page and pull all those widgets out of any one of those widget areas the conditional statement guarding the markup will fail. Big time. And to our benefit. No widgets. No markup. Dead&nbsp;simple.</p>
<p>Just the way we like things around&nbsp;here.</p>
<h2>How To Create a WordPress&nbsp;Theme</h2>
<p>This post is part of a <a href="http://themeshaper.com/wordpress-themes-templates-tutorial/">WordPress Themes Tutorial</a> that will show you how to create a powerful WordPress Theme from scratch. Read it from the beginning and code yourself up something&nbsp;awesome.</p>
<ol>
<li><a href="http://themeshaper.com/wordpress-themes-templates-tutorial/">WordPress Theme Tutorial&nbsp;Introduction</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-development-tools-tutorial/">Theme Development&nbsp;Tools</a></li>
<li><a href="http://themeshaper.com/creating-wordpress-theme-html-structure-tutorial/">Creating a Theme HTML&nbsp;Structure</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-template-directory-structure-tutorial/">Template and Directory&nbsp;Structure</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-header-template-tutorial/">The Header&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-index-template-tutorial/">The Index&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-single-post-post-attachment-404-templates-tutorial/">The Single Post, Post Attachment, &#038; 404&nbsp;Templates</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-comments-template-tutorial/">The Comments&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-search-page-template-tutorial/">The Search Template &#038; The Page&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/archive-author-category-tags-template/">The Archive, Author, Category &#038; Tags&nbsp;Template</a></li>
<li>The Sidebar&nbsp;Template</li>
<li><a href="http://themeshaper.com/reset-rebuild-wordpress-theme-css-define-layouts/">Reset-Rebuild Theme CSS &#038; Define Your&nbsp;Layouts</a></li>
</ol>
Similar Posts:<ul><li><a href="http://themeshaper.com/wordpress-menu-tricks/" rel="bookmark" title="March 30, 2009">WordPress Menu&nbsp;Tricks</a></li>

<li><a href="http://themeshaper.com/collapsing-wordpress-widget-ready-areas-sidebars/" rel="bookmark" title="August 7, 2008">Collapsing WordPress Widget-Ready Areas &#038;&nbsp;Sidebars</a></li>

<li><a href="http://themeshaper.com/we-need-to-kill-the-sidebar/" rel="bookmark" title="April 16, 2008">We Need To Kill The&nbsp;Sidebar</a></li>
</ul><!-- Similar Posts took 4.243 ms --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=Kp1J-PPmaG8:fPH0ycKxXFI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=Kp1J-PPmaG8:fPH0ycKxXFI:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=Kp1J-PPmaG8:fPH0ycKxXFI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=Kp1J-PPmaG8:fPH0ycKxXFI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=Kp1J-PPmaG8:fPH0ycKxXFI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=Kp1J-PPmaG8:fPH0ycKxXFI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=Kp1J-PPmaG8:fPH0ycKxXFI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=Kp1J-PPmaG8:fPH0ycKxXFI:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ThemeShaper/~4/Kp1J-PPmaG8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://themeshaper.com/wordpress-theme-sidebar-template/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		<feedburner:origLink>http://themeshaper.com/wordpress-theme-sidebar-template/</feedburner:origLink></item>
		<item>
		<title>The Archive, Author, Category &amp; Tags Template</title>
		<link>http://feedproxy.google.com/~r/ThemeShaper/~3/JgWs6hUUx_I/</link>
		<comments>http://themeshaper.com/archive-author-category-tags-template/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 11:00:15 +0000</pubDate>
		<dc:creator>Ian Stewart</dc:creator>
				<category><![CDATA[Theme Tips]]></category>

		<guid isPermaLink="false">http://themeshaper.com/?p=1951</guid>
		<description><![CDATA[Much like we did with index.php, we’re going to get one master template done right and use it to build our other templates. Our master Template in this case is the Archive&#160;Template.
What archive.php does (and all it’s related templates) is show posts based on a select criteria. A date range, or posts by a certain [...]]]></description>
			<content:encoded><![CDATA[<p><strong class="caps">Much like we did</strong> with <code>index.php</code>, we’re going to get one master template done right and use it to build our other templates. Our master Template in this case is the Archive&nbsp;Template.</p>
<p>What <code>archive.php</code> does (and all it’s related templates) is show posts based on a select criteria. A date range, or posts by a certain author, a category, or a tag. So, basically, it’s a lot like <code>index.php</code>. If you can read the name of the template you can figure out what it&#8217;s going to spit&nbsp;out.</p>
<p>Let’s start again with our <em>template-template</em> from the previous lessons and build on top of&nbsp;it.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p195132"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code" id="p1951code32"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> get_header<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
		<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;container&quot;</span><span style="color: #339933;">&gt;</span>	
			<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;content&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-above&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;navigation&quot;</span><span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#nav-above --&gt;
</span>
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post-&lt;?php the_ID(); ?&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> post_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#post-&lt;?php the_ID(); </span><span style="color: #000000; font-weight: bold;">?&gt;</span> <span style="color: #339933;">--&gt;</span>			
&nbsp;
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-below&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;navigation&quot;</span><span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#nav-below --&gt;					
</span>
&nbsp;
			<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#content --&gt;		
</span>		<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#container --&gt;
</span>		
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_sidebar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>	
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_footer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h2>The Archive&nbsp;Template</h2>
<p>Here’s the scheme of an Archive&nbsp;Template:</p>
<ol>
<li>Call&nbsp;<code>the_post()</code></li>
<li>Check to see what kind of template this&nbsp;is</li>
<li>Produce an appropriate&nbsp;template</li>
<li>Rewind the posts with&nbsp;<code>rewind_posts()</code></li>
<li>Do the usual <em>loopy</em> WordPress&nbsp;stuff</li>
</ol>
<p>Here’s the #content of your <code>archive.php</code> Template. Note the <a href="http://codex.wordpress.org/Conditional_Tags">Conditional Tags</a> at the top for checking to see what kind of template we’re&nbsp;in.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p195133"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
</pre></td><td class="code" id="p1951code33"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>			
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> is_day<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
				<span style="color: #339933;">&lt;</span>h1 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;page-title&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <a href="http://www.php.net/printf"><span style="color: #990000;">printf</span></a><span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Daily Archives: &lt;span&gt;%s&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> get_the_time<span style="color: #009900;">&#40;</span>get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'date_format'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>h1<span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> is_month<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
				<span style="color: #339933;">&lt;</span>h1 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;page-title&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <a href="http://www.php.net/printf"><span style="color: #990000;">printf</span></a><span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Monthly Archives: &lt;span&gt;%s&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> get_the_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'F Y'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>h1<span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> is_year<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
				<span style="color: #339933;">&lt;</span>h1 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;page-title&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <a href="http://www.php.net/printf"><span style="color: #990000;">printf</span></a><span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Yearly Archives: &lt;span&gt;%s&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> get_the_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>h1<span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'paged'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'paged'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
				<span style="color: #339933;">&lt;</span>h1 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;page-title&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Blog Archives'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>h1<span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> rewind_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">;</span> <span style="color: #000088;">$total_pages</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">max_num_pages</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$total_pages</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-above&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;navigation&quot;</span><span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-previous&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php next_posts_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'&lt;span class=&quot;meta-nav&quot;&gt;&amp;laquo;&lt;/span&gt; Older posts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-next&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php previous_posts_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Newer posts &lt;span class=&quot;meta-nav&quot;&gt;&amp;raquo;&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#nav-above --&gt;
</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>			
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post-&lt;?php the_ID(); ?&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> post_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>h2 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-title&quot;</span><span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php the_permalink(); ?&gt;&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php printf( __('Permalink to <span style="color: #009933; font-weight: bold;">%s</span>', 'your-theme'), the_title_attribute('echo=0') ); ?&gt;&quot;</span> rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;bookmark&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>h2<span style="color: #339933;">&gt;</span>
&nbsp;
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-meta&quot;</span><span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;meta-prep meta-prep-author&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'By '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;author vcard&quot;</span><span style="color: #339933;">&gt;&lt;</span>a <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;url fn n&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo get_author_link( false, <span style="color: #006699; font-weight: bold;">$authordata-&gt;ID</span>, <span style="color: #006699; font-weight: bold;">$authordata-&gt;user_nicename</span> ); ?&gt;&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php printf( __( 'View all posts by <span style="color: #009933; font-weight: bold;">%s</span>', 'your-theme' ), <span style="color: #006699; font-weight: bold;">$authordata-&gt;display_name</span> ); ?&gt;&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_author<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;meta-sep&quot;</span><span style="color: #339933;">&gt;</span> <span style="color: #339933;">|</span> <span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;meta-prep meta-prep-entry-date&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Published '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-date&quot;</span><span style="color: #339933;">&gt;&lt;</span>abbr <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;published&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php the_time('Y-m-d<span style="color: #000099; font-weight: bold;">\T</span>H:i:sO') ?&gt;&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_time<span style="color: #009900;">&#40;</span> get_option<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'date_format'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>abbr<span style="color: #339933;">&gt;&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #000000; font-weight: bold;">&lt;?php</span> edit_post_link<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Edit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>meta-sep<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;|&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>edit-link<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
					<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">.</span>entry<span style="color: #339933;">-</span>meta <span style="color: #339933;">--&gt;</span>
&nbsp;
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-summary&quot;</span><span style="color: #339933;">&gt;</span>	
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_excerpt<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Continue reading &lt;span class=&quot;meta-nav&quot;&gt;&amp;raquo;&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
					<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">.</span>entry<span style="color: #339933;">-</span>summary <span style="color: #339933;">--&gt;</span>
&nbsp;
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-utility&quot;</span><span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cat-links&quot;</span><span style="color: #339933;">&gt;&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-utility-prep entry-utility-prep-cat-links&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Posted in '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <span style="color: #b1b100;">echo</span> get_the_category_list<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">', '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;meta-sep&quot;</span><span style="color: #339933;">&gt;</span> <span style="color: #339933;">|</span> <span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_tags<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'&lt;span class=&quot;tag-links&quot;&gt;&lt;span class=&quot;entry-utility-prep entry-utility-prep-tag-links&quot;&gt;'</span> <span style="color: #339933;">.</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tagged '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>meta-sep<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;|&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comments-link&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php comments_popup_link<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Leave a comment'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'1 Comment'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'% Comments'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #000000; font-weight: bold;">&lt;?php</span> edit_post_link<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Edit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>meta-sep<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;|&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>edit-link<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
					<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#entry-utility --&gt;	
</span>				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#post-&lt;?php the_ID(); </span><span style="color: #000000; font-weight: bold;">?&gt;</span> <span style="color: #339933;">--&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>			
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">;</span> <span style="color: #000088;">$total_pages</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">max_num_pages</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$total_pages</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-below&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;navigation&quot;</span><span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-previous&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php next_posts_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'&lt;span class=&quot;meta-nav&quot;&gt;&amp;laquo;&lt;/span&gt; Older posts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-next&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php previous_posts_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Newer posts &lt;span class=&quot;meta-nav&quot;&gt;&amp;raquo;&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#nav-below --&gt;
</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h2>The Author&nbsp;Template</h2>
<p>Not a lot is going to change with our Author Template. You&#8217;re going to like this one. Copy <code>archive.php</code> and rename it <code>author.php</code>. All we need to change is the page title&nbsp;section.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p195134"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1951code34"><pre class="php" style="font-family:monospace;">				<span style="color: #339933;">&lt;</span>h1 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;page-title author&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <a href="http://www.php.net/printf"><span style="color: #990000;">printf</span></a><span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Author Archives: &lt;span class=&quot;vcard&quot;&gt;%s&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;a class='url fn n' href='<span style="color: #006699; font-weight: bold;">$authordata-&gt;user_url</span>' title='<span style="color: #006699; font-weight: bold;">$authordata-&gt;display_name</span>' rel='me'&gt;<span style="color: #006699; font-weight: bold;">$authordata-&gt;display_name</span>&lt;/a&gt;&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>h1<span style="color: #339933;">&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$authordesc</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$authordata</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_description</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$authordesc</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> apply_filters<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'archive_meta'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;div class=&quot;archive-meta&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$authordesc</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/div&gt;'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Easy,&nbsp;right?</p>
<h2>The Category&nbsp;Template</h2>
<p>The Category Template is another simple template now that we have a proper Archive Template. Copy <code>archive.php</code> and rename it&nbsp;<code>category.php</code>.</p>
<p>Now open up <code>functions.php</code>. We’re going to drop a custom function—from the brilliant Sandbox Theme—in there that’s going to make our Category Template a little more&nbsp;usable.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p195135"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code" id="p1951code35"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// For category lists on category archives: Returns other categories except the current one (redundant)</span>
<span style="color: #000000; font-weight: bold;">function</span> cats_meow<span style="color: #009900;">&#40;</span><span style="color: #000088;">$glue</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$current_cat</span> <span style="color: #339933;">=</span> single_cat_title<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$separator</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$cats</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$separator</span><span style="color: #339933;">,</span> get_the_category_list<span style="color: #009900;">&#40;</span><span style="color: #000088;">$separator</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$cats</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$str</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/strstr"><span style="color: #990000;">strstr</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$str</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&gt;<span style="color: #006699; font-weight: bold;">$current_cat</span>&lt;&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<a href="http://www.php.net/unset"><span style="color: #990000;">unset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cats</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cats</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <a href="http://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/join"><span style="color: #990000;">join</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$glue</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cats</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// end cats_meow</span></pre></td></tr></table></div>

<p>Our custom function <code>cats_meow()</code> removes the current category from category pages. In other words, it gets rid of redundant categories in that list of categories we have just underneath the excerpt of our&nbsp;post.</p>
<p>Now, back in <code>category.php</code>, replace the page title section with the following&nbsp;code:</p>

<div class="wp_codebox"><table width="100%" ><tr id="p195136"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1951code36"><pre class="php" style="font-family:monospace;">				<span style="color: #339933;">&lt;</span>h1 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;page-title&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Category Archives:'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> <span style="color: #339933;">&lt;</span>span<span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php single_cat_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;&lt;/</span>span<span style="color: #339933;">&gt;&lt;/</span>h1<span style="color: #339933;">&gt;</span>
				<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$categorydesc</span> <span style="color: #339933;">=</span> category_description<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$categorydesc</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> apply_filters<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'archive_meta'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;div class=&quot;archive-meta&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$categorydesc</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/div&gt;'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>And in the .entry-utility div, replace&nbsp;…</p>

<div class="wp_codebox"><table width="100%" ><tr id="p195137"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1951code37"><pre class="php" style="font-family:monospace;">						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cat-links&quot;</span><span style="color: #339933;">&gt;&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-utility-prep entry-utility-prep-cat-links&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Posted in '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <span style="color: #b1b100;">echo</span> get_the_category_list<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">', '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>with the modified&nbsp;…</p>

<div class="wp_codebox"><table width="100%" ><tr id="p195138"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p1951code38"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$cats_meow</span> <span style="color: #339933;">=</span> cats_meow<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">', '</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #666666; font-style: italic;">// Returns categories other than the one queried ?&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cat-links&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <a href="http://www.php.net/printf"><span style="color: #990000;">printf</span></a><span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Also posted in %s'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cats_meow</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;meta-sep&quot;</span><span style="color: #339933;">&gt;</span> <span style="color: #339933;">|</span> <span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h2>The Tags&nbsp;Template</h2>
<p>The Tags Template is almost identical to the Category Template, except, well, it’s for Tags. You know the drill: copy <code>archive.php</code> and rename it&nbsp;<code>tag.php</code>.</p>
<p>We’ve also got a custom function—again, from the brilliant Sandbox Theme—for our <code>functions.php</code> called <code>tag_ur_it()</code>. It works just like <code>cats_meow()</code> except it removes redundant&nbsp;tags.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p195139"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code" id="p1951code39"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// For tag lists on tag archives: Returns other tags except the current one (redundant)</span>
<span style="color: #000000; font-weight: bold;">function</span> tag_ur_it<span style="color: #009900;">&#40;</span><span style="color: #000088;">$glue</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$current_tag</span> <span style="color: #339933;">=</span> single_tag_title<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>  <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$separator</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$tags</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$separator</span><span style="color: #339933;">,</span> get_the_tag_list<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$separator</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$tags</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$str</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/strstr"><span style="color: #990000;">strstr</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$str</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&gt;<span style="color: #006699; font-weight: bold;">$current_tag</span>&lt;&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<a href="http://www.php.net/unset"><span style="color: #990000;">unset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tags</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tags</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <a href="http://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/join"><span style="color: #990000;">join</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$glue</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tags</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// end tag_ur_it</span></pre></td></tr></table></div>

<p>Now, in <code>tag.php</code>, replace your page title&nbsp;with:</p>

<div class="wp_codebox"><table width="100%" ><tr id="p195140"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1951code40"><pre class="php" style="font-family:monospace;">				<span style="color: #339933;">&lt;</span>h1 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;page-title&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Tag Archives:'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> <span style="color: #339933;">&lt;</span>span<span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php single_tag_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;&lt;/</span>h1<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>and in .entry-utility, replace&nbsp;…</p>

<div class="wp_codebox"><table width="100%" ><tr id="p195141"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1951code41"><pre class="php" style="font-family:monospace;">						<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_tags<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'&lt;span class=&quot;tag-links&quot;&gt;&lt;span class=&quot;entry-utility-prep entry-utility-prep-tag-links&quot;&gt;'</span> <span style="color: #339933;">.</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tagged '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>meta-sep<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;|&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>with the modified&nbsp;…</p>

<div class="wp_codebox"><table width="100%" ><tr id="p195142"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p1951code42"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$tag_ur_it</span> <span style="color: #339933;">=</span> tag_ur_it<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">', '</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #666666; font-style: italic;">// Returns tags other than the one queried ?&gt;						</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;tag-links&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <a href="http://www.php.net/printf"><span style="color: #990000;">printf</span></a><span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Also tagged %s'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tag_ur_it</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>And that&#8217;s&nbsp;it!</p>
<h2>How To Create a WordPress&nbsp;Theme</h2>
<p>This post is part of a <a href="http://themeshaper.com/wordpress-themes-templates-tutorial/">WordPress Themes Tutorial</a> that will show you how to create a powerful WordPress Theme from scratch. Read it from the beginning and code yourself up something&nbsp;awesome.</p>
<ol>
<li><a href="http://themeshaper.com/wordpress-themes-templates-tutorial/">WordPress Theme Tutorial&nbsp;Introduction</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-development-tools-tutorial/">Theme Development&nbsp;Tools</a></li>
<li><a href="http://themeshaper.com/creating-wordpress-theme-html-structure-tutorial/">Creating a Theme HTML&nbsp;Structure</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-template-directory-structure-tutorial/">Template and Directory&nbsp;Structure</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-header-template-tutorial/">The Header&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-index-template-tutorial/">The Index&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-single-post-post-attachment-404-templates-tutorial/">The Single Post, Post Attachment, &#038; 404&nbsp;Templates</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-comments-template-tutorial/">The Comments&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-search-page-template-tutorial/">The Search Template &#038; The Page&nbsp;Template</a></li>
<li>The Archive, Author, Category &#038; Tags&nbsp;Template</li>
<li><a href="http://themeshaper.com/wordpress-theme-sidebar-template/">The Sidebar&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/reset-rebuild-wordpress-theme-css-define-layouts/">Reset-Rebuild Theme CSS &#038; Define Your&nbsp;Layouts</a></li>
</ol>
Similar Posts:<ul><li><a href="http://themeshaper.com/wordpress-theme-index-template-tutorial/" rel="bookmark" title="June 29, 2009">The WordPress Theme Index&nbsp;Template</a></li>

<li><a href="http://themeshaper.com/wordpress-theme-single-post-post-attachment-404-templates-tutorial/" rel="bookmark" title="June 30, 2009">The WordPress Theme Single Post, Post Attachment, &#038; 404&nbsp;Templates</a></li>

<li><a href="http://themeshaper.com/wordpress-theme-template-directory-structure-tutorial/" rel="bookmark" title="June 25, 2009">WordPress Theme Template &#038; Directory&nbsp;Structure</a></li>
</ul><!-- Similar Posts took 3.856 ms --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=JgWs6hUUx_I:478CdZ2EtZo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=JgWs6hUUx_I:478CdZ2EtZo:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=JgWs6hUUx_I:478CdZ2EtZo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=JgWs6hUUx_I:478CdZ2EtZo:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=JgWs6hUUx_I:478CdZ2EtZo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=JgWs6hUUx_I:478CdZ2EtZo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=JgWs6hUUx_I:478CdZ2EtZo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=JgWs6hUUx_I:478CdZ2EtZo:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ThemeShaper/~4/JgWs6hUUx_I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://themeshaper.com/archive-author-category-tags-template/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://themeshaper.com/archive-author-category-tags-template/</feedburner:origLink></item>
		<item>
		<title>The WordPress Theme Search Template and Page Template</title>
		<link>http://feedproxy.google.com/~r/ThemeShaper/~3/6UAOdHsnnJ8/</link>
		<comments>http://themeshaper.com/wordpress-theme-search-page-template-tutorial/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 11:00:11 +0000</pubDate>
		<dc:creator>Ian Stewart</dc:creator>
				<category><![CDATA[Theme Tips]]></category>

		<guid isPermaLink="false">http://themeshaper.com/?p=1909</guid>
		<description><![CDATA[The Search Template and The Page Template are vital to any complete WordPress Theme. And they’re both really easy to code. For both these two Templates we’ll start with our template-template again but, of course, each one is going to take it’s own different path.]]></description>
			<content:encoded><![CDATA[<p><strong class="caps">The Search Template and The Page Template</strong> are vital to any complete WordPress Theme. And they’re both really easy to code. For both these two Templates we’ll start with our template-template&nbsp;again.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p190943"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code" id="p1909code43"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> get_header<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
		<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;container&quot;</span><span style="color: #339933;">&gt;</span>	
			<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;content&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-above&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;navigation&quot;</span><span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#nav-above --&gt;
</span>
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post-&lt;?php the_ID(); ?&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> post_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#post-&lt;?php the_ID(); </span><span style="color: #000000; font-weight: bold;">?&gt;</span> <span style="color: #339933;">--&gt;</span>			
&nbsp;
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-below&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;navigation&quot;</span><span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#nav-below --&gt;					
</span>
&nbsp;
			<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#content --&gt;		
</span>		<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#container --&gt;
</span>		
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_sidebar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>	
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_footer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>But, of course, each one is going to take it’s own different&nbsp;path.</p>
<h2>The Search&nbsp;Template</h2>
<p>In <code>search.php</code> we’re going to reintroduce the loop back into our Template. This time with an IF statement—in case we don’t have any posts to loop&nbsp;through.</p>
<p>Here’s how it’ll work: IF we have posts, or, in other words, if there are posts that match the terms we’re searching for, THEN loop through them, sorta just like in <code>index.php</code>, but IF we don’t have posts to loop through, or, if there aren’t any posts that match our search terms, give our searchers another chance at this searching&nbsp;business.</p>
<p>In code, it would look like&nbsp;this:</p>

<div class="wp_codebox"><table width="100%" ><tr id="p190944"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code" id="p1909code44"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> get_header<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
		<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;container&quot;</span><span style="color: #339933;">&gt;</span>	
			<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;content&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>				
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;!--</span> this is our loop <span style="color: #339933;">--&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">else</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;!--</span> here<span style="color: #0000ff;">'s where we'</span>ll put a search form <span style="color: #b1b100;">if</span> there<span style="color: #0000ff;">'re no posts --&gt;
&nbsp;
&lt;?php endif; ?&gt;			
&nbsp;
			&lt;/div&gt;&lt;!-- #content --&gt;		
		&lt;/div&gt;&lt;!-- #container --&gt;
&nbsp;
&lt;?php get_sidebar(); ?&gt;	
&lt;?php get_footer(); ?&gt;</span></pre></td></tr></table></div>

<p>Pretty straightforward, right?&nbsp;Almost.</p>
<p>I like to keep all my index-ey Templates the same: Post Title, Meta, Content (or excerpt), Utility links. But when WordPress searches for posts it also searches through <em>Pages</em>, which don’t need the post meta or utility links displayed. So, in our loop, we’re going to check and see if we’re dealing with a post or a&nbsp;page.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p190945"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1909code45"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'post'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Wrap any code with that IF statement and it will only show if we’re dealing with a page. Now that we understand what’s going on, here’s what the #content div of our search template will look&nbsp;like:</p>

<div class="wp_codebox"><table width="100%" ><tr id="p190946"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
</pre></td><td class="code" id="p1909code46"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
				<span style="color: #339933;">&lt;</span>h1 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;page-title&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Search Results for: '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;</span>span<span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_search_query<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;&lt;/</span>h1<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">;</span> <span style="color: #000088;">$total_pages</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">max_num_pages</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$total_pages</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-above&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;navigation&quot;</span><span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-previous&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php next_posts_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'&lt;span class=&quot;meta-nav&quot;&gt;&amp;laquo;&lt;/span&gt; Older posts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-next&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php previous_posts_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Newer posts &lt;span class=&quot;meta-nav&quot;&gt;&amp;raquo;&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#nav-above --&gt;
</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>							
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post-&lt;?php the_ID(); ?&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> post_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>h2 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-title&quot;</span><span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php the_permalink(); ?&gt;&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php printf( __('Permalink to <span style="color: #009933; font-weight: bold;">%s</span>', 'your-theme'), the_title_attribute('echo=0') ); ?&gt;&quot;</span> rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;bookmark&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>h2<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'post'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>									
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-meta&quot;</span><span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;meta-prep meta-prep-author&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'By '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;author vcard&quot;</span><span style="color: #339933;">&gt;&lt;</span>a <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;url fn n&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo get_author_link( false, <span style="color: #006699; font-weight: bold;">$authordata-&gt;ID</span>, <span style="color: #006699; font-weight: bold;">$authordata-&gt;user_nicename</span> ); ?&gt;&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php printf( __( 'View all posts by <span style="color: #009933; font-weight: bold;">%s</span>', 'your-theme' ), <span style="color: #006699; font-weight: bold;">$authordata-&gt;display_name</span> ); ?&gt;&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_author<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;meta-sep&quot;</span><span style="color: #339933;">&gt;</span> <span style="color: #339933;">|</span> <span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;meta-prep meta-prep-entry-date&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Published '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-date&quot;</span><span style="color: #339933;">&gt;&lt;</span>abbr <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;published&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php the_time('Y-m-d<span style="color: #000099; font-weight: bold;">\T</span>H:i:sO') ?&gt;&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_time<span style="color: #009900;">&#40;</span> get_option<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'date_format'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>abbr<span style="color: #339933;">&gt;&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #000000; font-weight: bold;">&lt;?php</span> edit_post_link<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Edit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>meta-sep<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;|&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>edit-link<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
					<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">.</span>entry<span style="color: #339933;">-</span>meta <span style="color: #339933;">--&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-summary&quot;</span><span style="color: #339933;">&gt;</span>	
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_excerpt<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Continue reading &lt;span class=&quot;meta-nav&quot;&gt;&amp;raquo;&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_link_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'before=&lt;div class=&quot;page-link&quot;&gt;'</span> <span style="color: #339933;">.</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Pages:'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;after=&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
					<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">.</span>entry<span style="color: #339933;">-</span>summary <span style="color: #339933;">--&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'post'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>									
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-utility&quot;</span><span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cat-links&quot;</span><span style="color: #339933;">&gt;&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-utility-prep entry-utility-prep-cat-links&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Posted in '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <span style="color: #b1b100;">echo</span> get_the_category_list<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">', '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;meta-sep&quot;</span><span style="color: #339933;">&gt;</span> <span style="color: #339933;">|</span> <span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_tags<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'&lt;span class=&quot;tag-links&quot;&gt;&lt;span class=&quot;entry-utility-prep entry-utility-prep-tag-links&quot;&gt;'</span> <span style="color: #339933;">.</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tagged '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>meta-sep<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;|&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comments-link&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php comments_popup_link<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Leave a comment'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'1 Comment'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'% Comments'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #000000; font-weight: bold;">&lt;?php</span> edit_post_link<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Edit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>meta-sep<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;|&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>edit-link<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
					<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#entry-utility --&gt;	
</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>					
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#post-&lt;?php the_ID(); </span><span style="color: #000000; font-weight: bold;">?&gt;</span> <span style="color: #339933;">--&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">;</span> <span style="color: #000088;">$total_pages</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">max_num_pages</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$total_pages</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-below&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;navigation&quot;</span><span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-previous&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php next_posts_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'&lt;span class=&quot;meta-nav&quot;&gt;&amp;laquo;&lt;/span&gt; Older posts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-next&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php previous_posts_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Newer posts &lt;span class=&quot;meta-nav&quot;&gt;&amp;raquo;&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#nav-below --&gt;
</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>			
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">else</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post-0&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post no-results not-found&quot;</span><span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>h2 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-title&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Nothing Found'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>h2<span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-content&quot;</span><span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Sorry, but nothing matched your search criteria. Please try again with some different keywords.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_search_form<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>						
					<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">.</span>entry<span style="color: #339933;">-</span>content <span style="color: #339933;">--&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h2>The Page&nbsp;Template</h2>
<p>You know what the Page Template is for. WordPress thinks of it as a post out of chronological order. We think of it as, well a page. But largely, it’s defined by what it doesn’t have: all the usual trappings of a blog&nbsp;post.</p>
<p>Except comments. Sometimes pages have comments. I don’t like them there. You might one day. So we’ll have to deal with that somehow. How about with … custom fields. If you want comments on a page you can add a custom field with Name and Value of &#8220;comments&#8221; to your page. Sounds good to&nbsp;me.</p>
<p>Here’s what you’ll need to for a perfect WordPress Page&nbsp;Template:</p>

<div class="wp_codebox"><table width="100%" ><tr id="p190947"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code" id="p1909code47"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> get_header<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
		<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;container&quot;</span><span style="color: #339933;">&gt;</span>	
			<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;content&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post-&lt;?php the_ID(); ?&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> post_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>h1 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-title&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>h1<span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-content&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_link_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'before=&lt;div class=&quot;page-link&quot;&gt;'</span> <span style="color: #339933;">.</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Pages:'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;after=&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>					
<span style="color: #000000; font-weight: bold;">&lt;?php</span> edit_post_link<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Edit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;span class=&quot;edit-link&quot;&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/span&gt;'</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
					<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">.</span>entry<span style="color: #339933;">-</span>content <span style="color: #339933;">--&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#post-&lt;?php the_ID(); </span><span style="color: #000000; font-weight: bold;">?&gt;</span> <span style="color: #339933;">--&gt;</span>			
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> get_post_custom_values<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'comments'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> comments_template<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// Add a custom field with Name and Value of &quot;comments&quot; to enable comments on this page ?&gt;			</span>
&nbsp;
			<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#content --&gt;		
</span>		<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#container --&gt;
</span>		
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_sidebar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>	
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_footer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h2>How To Create a WordPress&nbsp;Theme</h2>
<p>This post is part of a <a href="http://themeshaper.com/wordpress-themes-templates-tutorial/">WordPress Themes Tutorial</a> that will show you how to create a powerful WordPress Theme from scratch. Read it from the beginning and code yourself up something&nbsp;awesome.</p>
<ol>
<li><a href="http://themeshaper.com/wordpress-themes-templates-tutorial/">WordPress Theme Tutorial&nbsp;Introduction</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-development-tools-tutorial/">Theme Development&nbsp;Tools</a></li>
<li><a href="http://themeshaper.com/creating-wordpress-theme-html-structure-tutorial/">Creating a Theme HTML&nbsp;Structure</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-template-directory-structure-tutorial/">Template and Directory&nbsp;Structure</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-header-template-tutorial/">The Header&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-index-template-tutorial/">The Index&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-single-post-post-attachment-404-templates-tutorial/">The Single Post, Post Attachment, &#038; 404&nbsp;Templates</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-comments-template-tutorial/">The Comments&nbsp;Template</a></li>
<li>The Search Template &#038; The Page&nbsp;Template</li>
<li><a href="http://themeshaper.com/archive-author-category-tags-template/">The Archive, Author, Category &#038; Tags&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-sidebar-template/">The Sidebar&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/reset-rebuild-wordpress-theme-css-define-layouts/">Reset-Rebuild Theme CSS &#038; Define Your&nbsp;Layouts</a></li>
</ol>
Similar Posts:<ul><li><a href="http://themeshaper.com/archive-author-category-tags-template/" rel="bookmark" title="July 3, 2009">The Archive, Author, Category &#038; Tags&nbsp;Template</a></li>

<li><a href="http://themeshaper.com/wordpress-theme-single-post-post-attachment-404-templates-tutorial/" rel="bookmark" title="June 30, 2009">The WordPress Theme Single Post, Post Attachment, &#038; 404&nbsp;Templates</a></li>

<li><a href="http://themeshaper.com/wordpress-themes-templates-tutorial/" rel="bookmark" title="June 22, 2009">How To Create a WordPress Theme: The Ultimate WordPress Theme&nbsp;Tutorial</a></li>
</ul><!-- Similar Posts took 4.287 ms --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=6UAOdHsnnJ8:NHetHXEs99Q:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=6UAOdHsnnJ8:NHetHXEs99Q:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=6UAOdHsnnJ8:NHetHXEs99Q:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=6UAOdHsnnJ8:NHetHXEs99Q:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=6UAOdHsnnJ8:NHetHXEs99Q:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=6UAOdHsnnJ8:NHetHXEs99Q:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=6UAOdHsnnJ8:NHetHXEs99Q:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=6UAOdHsnnJ8:NHetHXEs99Q:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ThemeShaper/~4/6UAOdHsnnJ8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://themeshaper.com/wordpress-theme-search-page-template-tutorial/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://themeshaper.com/wordpress-theme-search-page-template-tutorial/</feedburner:origLink></item>
		<item>
		<title>The WordPress Theme Comments Template</title>
		<link>http://feedproxy.google.com/~r/ThemeShaper/~3/9TYJBf7C9dE/</link>
		<comments>http://themeshaper.com/wordpress-theme-comments-template-tutorial/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 11:00:03 +0000</pubDate>
		<dc:creator>Ian Stewart</dc:creator>
				<category><![CDATA[Theme Tips]]></category>

		<guid isPermaLink="false">http://themeshaper.com/?p=1903</guid>
		<description><![CDATA[I hate the Comments Template. There, I said it. It can be a confusing mess. In version 2.7, WordPress introduced a simpler way of producing Comments Templates—which was no help if you wanted to separate your comments and trackbacks or have custom comment markup. It’s still&#160;confusing.
Luckily for you, I’ve sorted it out. Confusing still, yes. [...]]]></description>
			<content:encoded><![CDATA[<p><strong class="caps">I hate the Comments Template</strong>. There, I said it. It can be a confusing mess. In version 2.7, WordPress introduced a simpler way of producing Comments Templates—which was no help if you wanted to separate your comments and trackbacks or have custom comment markup. It’s still&nbsp;confusing.</p>
<p>Luckily for you, I’ve sorted it out. Confusing still, yes. But sorted out. For this tutorial on the Comments Template I’m basically going to walk you through what’s going to happen, show you some custom code snippets you’ll need to add to your <code>functions.php</code>, and then drop the whole thing on you. Hopefully, it’ll start to make sense. But at they very least you’ll have a wicked comments&nbsp;template.</p>
<p>Let’s take a look at a quick list of what’s going on in this&nbsp;Template.</p>
<ol>
<li>Prevent loading for bots and on password protected&nbsp;posts</li>
<li>Check if there are&nbsp;comments</li>
<li>Count the number of comments and trackbacks (or&nbsp;pings)</li>
<li>If there are comments, show the comments—with navigation for paginated&nbsp;comments</li>
<li>If there are trackbacks, show the&nbsp;trackbacks</li>
<li>If comments are open, show the comments “respond”&nbsp;form</li>
</ol>
<p>That’s a lot of stuff going on for one template. But written out like that, it’s pretty&nbsp;straightforward.</p>
<h2>Custom Callbacks for Comments and&nbsp;Trackbacks</h2>
<p>Now, with WordPress 2.7 came the function <code>wp_list_comments()</code> that conveniently spits out an ordered list of comments and trackbacks markup for your post (threaded too). Convenient if you want that. And we don’t. We want separated threaded comments and trackbacks, with our own custom&nbsp;markup.</p>
<p>To make the comments template code I’m going to give you work, you’ll need a set of custom callbacks for your list of Comments and Trackbacks. Add the following 2 functions to your theme <code>functions.php</code>&nbsp;file.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p190352"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code" id="p1903code52"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Custom callback to list comments in the your-theme style</span>
<span style="color: #000000; font-weight: bold;">function</span> custom_comments<span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment</span><span style="color: #339933;">,</span> <span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <span style="color: #000088;">$depth</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'comment'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$comment</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'comment_depth'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$depth</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">?&gt;</span>
  	<span style="color: #339933;">&lt;</span>li id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comment-&lt;?php comment_ID() ?&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&gt;</span>
  		<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comment-author vcard&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php commenter_link<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
  		<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comment-meta&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <a href="http://www.php.net/printf"><span style="color: #990000;">printf</span></a><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Posted %1$s at %2$s &lt;span class=&quot;meta-sep&quot;&gt;|&lt;/span&gt; &lt;a href=&quot;%3$s&quot; title=&quot;Permalink to this comment&quot;&gt;Permalink&lt;/a&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
  					get_comment_date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
  					get_comment_time<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
  					<span style="color: #0000ff;">'#comment-'</span> <span style="color: #339933;">.</span> get_comment_ID<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  					edit_comment_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Edit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' &lt;span class=&quot;meta-sep&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;edit-link&quot;&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_approved</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&lt;span class='unapproved'&gt;Your comment is awaiting moderation.&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
          <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comment-content&quot;</span><span style="color: #339933;">&gt;</span>
      		<span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_text<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
  		<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">// echo the comment reply link</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'all'</span> <span style="color: #339933;">||</span> get_comment_type<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'comment'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
				comment_reply_link<span style="color: #009900;">&#40;</span><a href="http://www.php.net/array_merge"><span style="color: #990000;">array_merge</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
					<span style="color: #0000ff;">'reply_text'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Reply'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> 
					<span style="color: #0000ff;">'login_text'</span> <span style="color: #339933;">=&gt;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Log in to reply.'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
					<span style="color: #0000ff;">'depth'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$depth</span><span style="color: #339933;">,</span>
					<span style="color: #0000ff;">'before'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;div class=&quot;comment-reply-link&quot;&gt;'</span><span style="color: #339933;">,</span> 
					<span style="color: #0000ff;">'after'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'&lt;/div&gt;'</span>
				<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// end custom_comments</span></pre></td></tr></table></div>


<div class="wp_codebox"><table width="100%" ><tr id="p190353"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p1903code53"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Custom callback to list pings</span>
<span style="color: #000000; font-weight: bold;">function</span> custom_pings<span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment</span><span style="color: #339933;">,</span> <span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <span style="color: #000088;">$depth</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'comment'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$comment</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">?&gt;</span>
    		<span style="color: #339933;">&lt;</span>li id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comment-&lt;?php comment_ID() ?&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&gt;</span>
    			<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comment-author&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <a href="http://www.php.net/printf"><span style="color: #990000;">printf</span></a><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'By %1$s on %2$s at %3$s'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    					get_comment_author_link<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    					get_comment_date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    					get_comment_time<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    					edit_comment_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Edit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' &lt;span class=&quot;meta-sep&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;edit-link&quot;&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_approved</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'\t\t\t\t\t&lt;span class=&quot;unapproved&quot;&gt;Your trackback is awaiting moderation.&lt;/span&gt;\n'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
            <span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comment-content&quot;</span><span style="color: #339933;">&gt;</span>
    			<span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_text<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
			<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// end custom_pings</span></pre></td></tr></table></div>

<p>Those look kind of hairy don’t they? But you’re better off for it. Now you have access to the comments markup. I think the markup I’ve got in there is pretty sweet and will let you make a <strong>lot</strong> of changes with just CSS alone, but if you do want to alter the markup, well, there it&nbsp;is.</p>
<p>We’ll also need a special custom function that the <code>custom_comments()</code> is calling. This function will markup the gravatar we’re using so it fits into the microformat schema for&nbsp;<em>hcard</em>.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p190354"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p1903code54"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Produces an avatar image with the hCard-compliant photo class</span>
<span style="color: #000000; font-weight: bold;">function</span> commenter_link<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$commenter</span> <span style="color: #339933;">=</span> get_comment_author_link<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="http://www.php.net/ereg"><span style="color: #990000;">ereg</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'&lt;a[^&gt;]* class=[^&gt;]+&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$commenter</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$commenter</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ereg_replace"><span style="color: #990000;">ereg_replace</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'(&lt;a[^&gt;]* class=[\'&quot;]?)'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'\\1url '</span> <span style="color: #339933;">,</span> <span style="color: #000088;">$commenter</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$commenter</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ereg_replace"><span style="color: #990000;">ereg_replace</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'(&lt;a )/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'\\1class=&quot;url &quot;'</span> <span style="color: #339933;">,</span> <span style="color: #000088;">$commenter</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$avatar_email</span> <span style="color: #339933;">=</span> get_comment_author_email<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$avatar</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;class='avatar&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;class='photo avatar&quot;</span><span style="color: #339933;">,</span> get_avatar<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$avatar_email</span><span style="color: #339933;">,</span> 80 <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$avatar</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' &lt;span class=&quot;fn n&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$commenter</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/span&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// end commenter_link</span></pre></td></tr></table></div>

<p>If you want to change the default size of your gravatar just change the 80 in <code>get_avatar( $avatar_email, 80 ) )</code>. The 80 is the size in pixels of your&nbsp;gravatar.</p>
<h2>The Comments&nbsp;Template</h2>
<p>I haven’t scared you away have I? I’ll be honest, it’s not that scary. Here’s the comments template with some helpful PHP comments that should guide you along in understanding what’s&nbsp;happening.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p190355"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
</pre></td><td class="code" id="p1903code55"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* The Comments Template — with, er, comments! */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>			
			<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comments&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* Run some checks for bots and password protected posts */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>	
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #000088;">$req</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'require_name_email'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Checks if fields are required.</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'comments.php'</span> <span style="color: #339933;">==</span> <a href="http://www.php.net/basename"><span style="color: #990000;">basename</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SCRIPT_FILENAME'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
		<a href="http://www.php.net/die"><span style="color: #990000;">die</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Please do not load this page directly. Thanks!'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_password</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_COOKIE</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wp-postpass_'</span> <span style="color: #339933;">.</span> COOKIEHASH<span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_password</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
				<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nopassword&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'This post is password protected. Enter the password to view any comments.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
			<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">.</span>comments <span style="color: #339933;">--&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
		<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* See IF there are comments and do the comments stuff! */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>						
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> have_comments<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* Count the number of comments and trackbacks (or pings) */</span>
<span style="color: #000088;">$ping_count</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$comment_count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$comments</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$comment</span> <span style="color: #009900;">&#41;</span>
	get_comment_type<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;comment&quot;</span> ? <span style="color: #339933;">++</span><span style="color: #000088;">$comment_count</span> <span style="color: #339933;">:</span> <span style="color: #339933;">++</span><span style="color: #000088;">$ping_count</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* IF there are comments, show the comments */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$comments_by_type</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'comment'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comments-list&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comments&quot;</span><span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>h3<span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <a href="http://www.php.net/printf"><span style="color: #990000;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment_count</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span> ? __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;span&gt;%d&lt;/span&gt; Comments'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;span&gt;One&lt;/span&gt; Comment'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$comment_count</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>h3<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* If there are enough comments, build the comment navigation  */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>					
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$total_pages</span> <span style="color: #339933;">=</span> get_comment_pages_count<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$total_pages</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
					<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comments-nav-above&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comments-navigation&quot;</span><span style="color: #339933;">&gt;</span>
								<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;paginated-comments-links&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php paginate_comments_links<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#comments-nav-above --&gt;					
</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>					
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* An ordered list of our custom comments callback, custom_comments(), in functions.php   */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>				
					<span style="color: #339933;">&lt;</span>ol<span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_list_comments<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'type=comment&amp;callback=custom_comments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
					<span style="color: #339933;">&lt;/</span>ol<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* If there are enough comments, build the comment navigation */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$total_pages</span> <span style="color: #339933;">=</span> get_comment_pages_count<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$total_pages</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>					
	  			<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comments-nav-below&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comments-navigation&quot;</span><span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;paginated-comments-links&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php paginate_comments_links<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
	        <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#comments-nav-below --&gt;
</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>					
&nbsp;
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#comments-list .comments --&gt;
</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/* if ( $comment_count ) */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* If there are trackbacks(pings), show the trackbacks  */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$comments_by_type</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pings'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;trackbacks-list&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comments&quot;</span><span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>h3<span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <a href="http://www.php.net/printf"><span style="color: #990000;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ping_count</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span> ? __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;span&gt;%d&lt;/span&gt; Trackbacks'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;span&gt;One&lt;/span&gt; Trackback'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ping_count</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>h3<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* An ordered list of our custom trackbacks callback, custom_pings(), in functions.php   */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>					
					<span style="color: #339933;">&lt;</span>ol<span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_list_comments<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'type=pings&amp;callback=custom_pings'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
					<span style="color: #339933;">&lt;/</span>ol<span style="color: #339933;">&gt;</span>				
&nbsp;
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#trackbacks-list .comments --&gt;			
</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span> <span style="color: #666666; font-style: italic;">/* if ( $ping_count ) */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span> <span style="color: #666666; font-style: italic;">/* if ( $comments ) */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* If comments are open, build the respond form */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'open'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_status</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;respond&quot;</span><span style="color: #339933;">&gt;</span>
    				<span style="color: #339933;">&lt;</span>h3<span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php comment_form_title<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Post a Comment'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Post a Reply to %s'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>h3<span style="color: #339933;">&gt;</span>
&nbsp;
    				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cancel-comment-reply&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php cancel_comment_reply_link<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'comment_registration'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$user_ID</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
					<span style="color: #339933;">&lt;</span>p id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;login-req&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <a href="http://www.php.net/printf"><span style="color: #990000;">printf</span></a><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'You must be &lt;a href=&quot;%s&quot; title=&quot;Log in&quot;&gt;logged in&lt;/a&gt; to post a comment.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
					get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'siteurl'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/wp-login.php?redirect_to='</span> <span style="color: #339933;">.</span> get_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">else</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;formcontainer&quot;</span><span style="color: #339933;">&gt;</span>	
&nbsp;
&nbsp;
						<span style="color: #339933;">&lt;</span>form id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;commentform&quot;</span> action<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo get_option('siteurl'); ?&gt;/wp-comments-post.php&quot;</span> method<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$user_ID</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
							<span style="color: #339933;">&lt;</span>p id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;login&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <a href="http://www.php.net/printf"><span style="color: #990000;">printf</span></a><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;span class=&quot;loggedin&quot;&gt;Logged in as &lt;a href=&quot;%1$s&quot; title=&quot;Logged in as %2$s&quot;&gt;%2$s&lt;/a&gt;.&lt;/span&gt; &lt;span class=&quot;logout&quot;&gt;&lt;a href=&quot;%3$s&quot; title=&quot;Log out of this account&quot;&gt;Log out?&lt;/a&gt;&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
								get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'siteurl'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/wp-admin/profile.php'</span><span style="color: #339933;">,</span>
								wp_specialchars<span style="color: #009900;">&#40;</span><span style="color: #000088;">$user_identity</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
								wp_logout_url<span style="color: #009900;">&#40;</span>get_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">else</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
							<span style="color: #339933;">&lt;</span>p id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comment-notes&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Your email is &lt;em&gt;never&lt;/em&gt; published nor shared.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$req</span><span style="color: #009900;">&#41;</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Required fields are marked &lt;span class=&quot;required&quot;&gt;*&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
&nbsp;
              <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-section-author&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-section&quot;</span><span style="color: #339933;">&gt;</span>
								<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-label&quot;</span><span style="color: #339933;">&gt;&lt;</span>label <span style="color: #b1b100;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;author&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Name'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>label<span style="color: #339933;">&gt;</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$req</span><span style="color: #009900;">&#41;</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;span class=&quot;required&quot;&gt;*&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
								<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-input&quot;</span><span style="color: #339933;">&gt;&lt;</span>input id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;author&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;author&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo <span style="color: #006699; font-weight: bold;">$comment_author</span> ?&gt;&quot;</span> size<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;30&quot;</span> maxlength<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;20&quot;</span> tabindex<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;3&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
              <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#form-section-author .form-section --&gt;
</span>
              <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-section-email&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-section&quot;</span><span style="color: #339933;">&gt;</span>
								<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-label&quot;</span><span style="color: #339933;">&gt;&lt;</span>label <span style="color: #b1b100;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;email&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Email'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>label<span style="color: #339933;">&gt;</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$req</span><span style="color: #009900;">&#41;</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;span class=&quot;required&quot;&gt;*&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
								<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-input&quot;</span><span style="color: #339933;">&gt;&lt;</span>input id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;email&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;email&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo <span style="color: #006699; font-weight: bold;">$comment_author_email</span> ?&gt;&quot;</span> size<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;30&quot;</span> maxlength<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;50&quot;</span> tabindex<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;4&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
              <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#form-section-email .form-section --&gt;
</span>
              <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-section-url&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-section&quot;</span><span style="color: #339933;">&gt;</span>
								<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-label&quot;</span><span style="color: #339933;">&gt;&lt;</span>label <span style="color: #b1b100;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;url&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Website'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>label<span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
								<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-input&quot;</span><span style="color: #339933;">&gt;&lt;</span>input id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;url&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;url&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo <span style="color: #006699; font-weight: bold;">$comment_author_url</span> ?&gt;&quot;</span> size<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;30&quot;</span> maxlength<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;50&quot;</span> tabindex<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;5&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
              <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#form-section-url .form-section --&gt;
</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span> <span style="color: #666666; font-style: italic;">/* if ( $user_ID ) */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
              <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-section-comment&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-section&quot;</span><span style="color: #339933;">&gt;</span>
								<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-label&quot;</span><span style="color: #339933;">&gt;&lt;</span>label <span style="color: #b1b100;">for</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comment&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Comment'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>label<span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
								<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-textarea&quot;</span><span style="color: #339933;">&gt;&lt;</span>textarea id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comment&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comment&quot;</span> cols<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;45&quot;</span> rows<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;8&quot;</span> tabindex<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;6&quot;</span><span style="color: #339933;">&gt;&lt;/</span>textarea<span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
              <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#form-section-comment .form-section --&gt;
</span>              
              <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-allowed-tags&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-section&quot;</span><span style="color: #339933;">&gt;</span>
	              <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;&lt;</span>span<span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'You may use these &lt;abbr title=&quot;HyperText Markup Language&quot;&gt;HTML&lt;/abbr&gt; tags and attributes:'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span> <span style="color: #339933;">&lt;</span>code<span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <span style="color: #b1b100;">echo</span> allowed_tags<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>code<span style="color: #339933;">&gt;&lt;/</span>p<span style="color: #339933;">&gt;</span>
              <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> do_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'comment_form'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
							<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;form-submit&quot;</span><span style="color: #339933;">&gt;&lt;</span>input id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php _e('Post Comment', 'your-theme') ?&gt;&quot;</span> tabindex<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;7&quot;</span> <span style="color: #339933;">/&gt;&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;hidden&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comment_post_ID&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo <span style="color: #006699; font-weight: bold;">$id</span>; ?&gt;&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> comment_id_fields<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* Just … end everything. We're done here. Close it up. */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  
&nbsp;
						<span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#commentform --&gt;										
</span>					<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">.</span>formcontainer <span style="color: #339933;">--&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span> <span style="color: #666666; font-style: italic;">/* if ( get_option('comment_registration') &amp;&amp; !$user_ID ) */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#respond --&gt;
</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span> <span style="color: #666666; font-style: italic;">/* if ( 'open' == $post-&gt;comment_status ) */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
			<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#comments --&gt;</span></pre></td></tr></table></div>

<p>And that’s it. You’ve got a pretty sweet custom Comments Template to call your very&nbsp;own.</p>
<h2>How To Create a WordPress&nbsp;Theme</h2>
<p>This post is part of a <a href="http://themeshaper.com/wordpress-themes-templates-tutorial/">WordPress Themes Tutorial</a> that will show you how to create a powerful WordPress Theme from scratch. Read it from the beginning and code yourself up something&nbsp;awesome.</p>
<ol>
<li><a href="http://themeshaper.com/wordpress-themes-templates-tutorial/">WordPress Theme Tutorial&nbsp;Introduction</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-development-tools-tutorial/">Theme Development&nbsp;Tools</a></li>
<li><a href="http://themeshaper.com/creating-wordpress-theme-html-structure-tutorial/">Creating a Theme HTML&nbsp;Structure</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-template-directory-structure-tutorial/">Template and Directory&nbsp;Structure</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-header-template-tutorial/">The Header&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-index-template-tutorial/">The Index&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-single-post-post-attachment-404-templates-tutorial/">The Single Post, Post Attachment, &#038; 404&nbsp;Templates</a></li>
<li>The Comments&nbsp;Template</li>
<li><a href="http://themeshaper.com/wordpress-theme-search-page-template-tutorial/">The Search Template &#038; The Page&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/archive-author-category-tags-template/">The Archive, Author, Category &#038; Tags&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-sidebar-template/">The Sidebar&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/reset-rebuild-wordpress-theme-css-define-layouts/">Reset-Rebuild Theme CSS &#038; Define Your&nbsp;Layouts</a></li>
</ol>
Similar Posts:<ul><li><a href="http://themeshaper.com/wordpress-themes-templates-tutorial/" rel="bookmark" title="June 22, 2009">How To Create a WordPress Theme: The Ultimate WordPress Theme&nbsp;Tutorial</a></li>

<li><a href="http://themeshaper.com/wordpress-theme-sidebar-template/" rel="bookmark" title="July 6, 2009">The WordPress Theme Sidebar&nbsp;Template</a></li>

<li><a href="http://themeshaper.com/wordpress-theme-blank-framework/" rel="bookmark" title="August 28, 2008">Any WordPress Theme Can Be a Blank&nbsp;Framework</a></li>
</ul><!-- Similar Posts took 4.074 ms --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=9TYJBf7C9dE:_W1gmP8lj9c:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=9TYJBf7C9dE:_W1gmP8lj9c:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=9TYJBf7C9dE:_W1gmP8lj9c:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=9TYJBf7C9dE:_W1gmP8lj9c:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=9TYJBf7C9dE:_W1gmP8lj9c:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=9TYJBf7C9dE:_W1gmP8lj9c:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=9TYJBf7C9dE:_W1gmP8lj9c:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=9TYJBf7C9dE:_W1gmP8lj9c:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ThemeShaper/~4/9TYJBf7C9dE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://themeshaper.com/wordpress-theme-comments-template-tutorial/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		<feedburner:origLink>http://themeshaper.com/wordpress-theme-comments-template-tutorial/</feedburner:origLink></item>
		<item>
		<title>The WordPress Theme Single Post, Post Attachment, &amp; 404 Templates</title>
		<link>http://feedproxy.google.com/~r/ThemeShaper/~3/mwnHMx5lOGM/</link>
		<comments>http://themeshaper.com/wordpress-theme-single-post-post-attachment-404-templates-tutorial/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 11:00:35 +0000</pubDate>
		<dc:creator>Ian Stewart</dc:creator>
				<category><![CDATA[Theme Tips]]></category>

		<guid isPermaLink="false">http://themeshaper.com/?p=1893</guid>
		<description><![CDATA[You’ve built an index of all your posts, now you need to create a template to frame each piece of content (or missing content) on it’s own. The structure of single.php (and almost all the other templates we’ll be creating) is largely the same as index.php. In fact you can think of it as our template-template.]]></description>
			<content:encoded><![CDATA[<p><strong class="caps">You’ve built an index</strong> of all your posts, now you need to create a template to frame each piece of content (or missing content) on it’s&nbsp;own.</p>
<h2>The Template for&nbsp;Templates</h2>
<p>The structure of <code>single.php</code> (and almost all the other templates we’ll be creating) is largely the same as <code>index.php</code>. In fact you can think of it as our&nbsp;template-template.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189356"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code" id="p1893code56"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> get_header<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
		<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;container&quot;</span><span style="color: #339933;">&gt;</span>	
			<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;content&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-above&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;navigation&quot;</span><span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#nav-above --&gt;
</span>
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post-&lt;?php the_ID(); ?&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> post_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#post-&lt;?php the_ID(); </span><span style="color: #000000; font-weight: bold;">?&gt;</span> <span style="color: #339933;">--&gt;</span>			
&nbsp;
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-below&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;navigation&quot;</span><span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#nav-below --&gt;					
</span>
&nbsp;
			<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#content --&gt;		
</span>		<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#container --&gt;
</span>		
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_sidebar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>	
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_footer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>But there are going to be some notable differences. Starting with <code>the_post()</code> and&nbsp;<code>comments_template()</code>.</p>
<p>We’ll be calling <code>the_post()</code> near the top of our page just after the opening of the content div and just before the navigation. We won’t need a loop in this template as WordPress knows just what post we’re looking at thanks to&nbsp;<code>the_permalink()</code>.</p>
<p>And since this is a single post, we’ll need the <code>comments_template()</code>. And because we’ll be separating our comments and trackbacks when we come to coding up <code>comments.php</code>, we need to call it just like&nbsp;so:</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189357"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1893code57"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> comments_template<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><code>comments_template()</code> will need to go just before the close of the #content div right after the&nbsp;navigation.</p>
<h2>Single Post&nbsp;Navigation</h2>
<p>Instead of using the poorly named <code>next_posts_link()</code> and <code>previous_posts_link()</code> we’ll be using the mostly accurately named <code>previous_post_link()</code> and <code>next_post_link()</code>. They do just what you think they&nbsp;do.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189358"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p1893code58"><pre class="php" style="font-family:monospace;">				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-above&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;navigation&quot;</span><span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-previous&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php previous_post_link<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'%link'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;span class=&quot;meta-nav&quot;&gt;&amp;laquo;&lt;/span&gt; %title'</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-next&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php next_post_link<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'%link'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'%title &lt;span class=&quot;meta-nav&quot;&gt;&amp;raquo;&lt;/span&gt;'</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#nav-above --&gt;</span></pre></td></tr></table></div>


<div class="wp_codebox"><table width="100%" ><tr id="p189359"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p1893code59"><pre class="php" style="font-family:monospace;">				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-below&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;navigation&quot;</span><span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-previous&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php previous_post_link<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'%link'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;span class=&quot;meta-nav&quot;&gt;&amp;laquo;&lt;/span&gt; %title'</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-next&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php next_post_link<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'%link'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'%title &lt;span class=&quot;meta-nav&quot;&gt;&amp;raquo;&lt;/span&gt;'</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#nav-below --&gt;</span></pre></td></tr></table></div>

<h2>Single Post&nbsp;Titles</h2>
<p>If you remember from our header.php lesson, we used a dynamic IF statement to clear the way for our Single post titles to take precedence on the page in the eyes of screen readers. We take advantage of this in this and all the rest of our Theme Templates by wrapping the title in and h1&nbsp;tag.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189360"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1893code60"><pre class="php" style="font-family:monospace;">					<span style="color: #339933;">&lt;</span>h1 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-title&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>h1<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>You’ll notice that our post title code is a little simpler too. The benefit of not having to link to anything&nbsp;now.</p>
<h2>Single Post Entry Utility&nbsp;Links</h2>
<p>The entry utility is … complicated. Here I think you’ll see the benefit of getting something right once and standing on the shoulders of&nbsp;others.</p>
<p>Before we take a look at the code we should think about why it is complicated. Because of the way comments work in WordPress we need to account for a few different scenarios: Open comments and trackbacks; only trackbacks open; only comments open; comments and trackbacks closed. And that means … what looks like a mess of IF&nbsp;statements.</p>
<p>It can be daunting. The code is commented but remember to look for the blocks of IF and ELSEIF statements and you’ll be&nbsp;fine.</p>
<p>We also want to print a link to our permalink here for bookmarking purposes and the RSS for this particular single post—useful for tracking developing&nbsp;conversations.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189361"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code" id="p1893code61"><pre class="php" style="font-family:monospace;">					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-utility&quot;</span><span style="color: #339933;">&gt;</span>
					<span style="color: #000000; font-weight: bold;">&lt;?php</span> <a href="http://www.php.net/printf"><span style="color: #990000;">printf</span></a><span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'This entry was posted in %1$s%2$s. Bookmark the &lt;a href=&quot;%3$s&quot; title=&quot;Permalink to %4$s&quot; rel=&quot;bookmark&quot;&gt;permalink&lt;/a&gt;. Follow any comments here with the &lt;a href=&quot;%5$s&quot; title=&quot;Comments RSS to %4$s&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot;&gt;RSS feed for this post&lt;/a&gt;.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
						get_the_category_list<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">', '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
						get_the_tag_list<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">' and tagged '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">', '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
						get_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
						the_title_attribute<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'echo=0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
						comments_rss<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'open'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_status</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'open'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ping_status</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #666666; font-style: italic;">// Comments and trackbacks open ?&gt;</span>
						<span style="color: #000000; font-weight: bold;">&lt;?php</span> <a href="http://www.php.net/printf"><span style="color: #990000;">printf</span></a><span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'&lt;a class=&quot;comment-link&quot; href=&quot;#respond&quot; title=&quot;Post a comment&quot;&gt;Post a comment&lt;/a&gt; or leave a trackback: &lt;a class=&quot;trackback-link&quot; href=&quot;%s&quot; title=&quot;Trackback URL for your post&quot; rel=&quot;trackback&quot;&gt;Trackback URL&lt;/a&gt;.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> get_trackback_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'open'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_status</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'open'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ping_status</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #666666; font-style: italic;">// Only trackbacks open ?&gt;</span>
						<span style="color: #000000; font-weight: bold;">&lt;?php</span> <a href="http://www.php.net/printf"><span style="color: #990000;">printf</span></a><span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Comments are closed, but you can leave a trackback: &lt;a class=&quot;trackback-link&quot; href=&quot;%s&quot; title=&quot;Trackback URL for your post&quot; rel=&quot;trackback&quot;&gt;Trackback URL&lt;/a&gt;.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> get_trackback_url<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'open'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_status</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'open'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ping_status</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #666666; font-style: italic;">// Only comments open ?&gt;</span>
						<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Trackbacks are closed, but you can &lt;a class=&quot;comment-link&quot; href=&quot;#respond&quot; title=&quot;Post a comment&quot;&gt;post a comment&lt;/a&gt;.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'open'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment_status</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'open'</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ping_status</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #666666; font-style: italic;">// Comments and trackbacks closed ?&gt;</span>
						<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Both comments and trackbacks are currently closed.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> edit_post_link<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Edit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>edit-link<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;/span&gt;&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
					<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">.</span>entry<span style="color: #339933;">-</span>utility <span style="color: #339933;">--&gt;</span></pre></td></tr></table></div>

<p>That wasn’t so bad was&nbsp;it? </p>
<h2>Single Post&nbsp;Content</h2>
<p>Unlike <code>index.php</code>, <code>single.php</code> content is pretty simple. Just one plain function call followed by&nbsp;<code>wp_link_pages()</code>.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189362"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1893code62"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_link_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'before=&lt;div class=&quot;page-link&quot;&gt;'</span> <span style="color: #339933;">.</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Pages:'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;after=&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h2>Post&nbsp;Attachments</h2>
<p>Not a lot of people use post attachments but they’re kinda interesting. When you add an image to your post you’re actually attaching it to the post. And, of course, you can attach more than just images. We’re going to make an <code>attachment.php</code> template but you can, if you like, adapt it further to cover other types of attachments like video, audio, and applications, by making <code>video.php</code>, <code>audio.php</code>, and <code>application.php</code> templates. There’s lots of different ways to be creative with attachment templates and&nbsp;WordPress.</p>
<p>The easiest way to proceed here is by copying <code>single.php</code>, renaming it <code>attachment.php</code>, and making the following&nbsp;changes.</p>
<p>First of all, delete the top navigation. We won’t need it at all here. Replace it with a page title that links back to your parent&nbsp;post.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189363"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1893code63"><pre class="php" style="font-family:monospace;">				<span style="color: #339933;">&lt;</span>h1 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;page-title&quot;</span><span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo get_permalink(<span style="color: #006699; font-weight: bold;">$post-&gt;post_parent</span>) ?&gt;&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php printf( __( 'Return to <span style="color: #009933; font-weight: bold;">%s</span>', 'your-theme' ), wp_specialchars( get_the_title(<span style="color: #006699; font-weight: bold;">$post-&gt;post_parent</span>), 1 ) ) ?&gt;&quot;</span> rev<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;attachment&quot;</span><span style="color: #339933;">&gt;&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;meta-nav&quot;</span><span style="color: #339933;">&gt;&amp;</span>laquo<span style="color: #339933;">;</span> <span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <span style="color: #b1b100;">echo</span> get_the_title<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_parent</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>h1<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Since the page title is now wrapped in h1 tags that means our post title should be wrapped in h2&nbsp;tags.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189364"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1893code64"><pre class="php" style="font-family:monospace;">					<span style="color: #339933;">&lt;</span>h2 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-title&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>h2<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Now, because our attachment template needs to actually show the attachment, our content needs to reflect that. And since most attachments are going to be images, we’ll want to check for that and cover that scenario with an IF&nbsp;statement.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189365"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code" id="p1893code65"><pre class="php" style="font-family:monospace;">					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-content&quot;</span><span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-attachment&quot;</span><span style="color: #339933;">&gt;</span>					
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> wp_attachment_is_image<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$att_image</span> <span style="color: #339933;">=</span> wp_get_attachment_image_src<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;medium&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
						<span style="color: #339933;">&lt;</span>p <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;attachment&quot;</span><span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo wp_get_attachment_url(<span style="color: #006699; font-weight: bold;">$post-&gt;id</span>); ?&gt;&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php the_title(); ?&gt;&quot;</span> rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;attachment&quot;</span><span style="color: #339933;">&gt;&lt;</span>img src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo <span style="color: #006699; font-weight: bold;">$att_image[0]</span>;?&gt;&quot;</span> width<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo <span style="color: #006699; font-weight: bold;">$att_image[1]</span>;?&gt;&quot;</span> height<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo <span style="color: #006699; font-weight: bold;">$att_image[2]</span>;?&gt;&quot;</span>  <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;attachment-medium&quot;</span> alt<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php <span style="color: #006699; font-weight: bold;">$post-&gt;post_excerpt</span>; ?&gt;&quot;</span> <span style="color: #339933;">/&gt;&lt;/</span>a<span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">else</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>		
						<span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo wp_get_attachment_url(<span style="color: #006699; font-weight: bold;">$post-&gt;ID</span>) ?&gt;&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo wp_specialchars( get_the_title(<span style="color: #006699; font-weight: bold;">$post-&gt;ID</span>), 1 ) ?&gt;&quot;</span> rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;attachment&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <span style="color: #b1b100;">echo</span> <a href="http://www.php.net/basename"><span style="color: #990000;">basename</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">guid</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>		
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>		
						<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>				
						<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-caption&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_excerpt</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> the_excerpt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Continue reading &lt;span class=&quot;meta-nav&quot;&gt;&amp;raquo;&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_link_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'before=&lt;div class=&quot;page-link&quot;&gt;'</span> <span style="color: #339933;">.</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Pages:'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;after=&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
					<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">.</span>entry<span style="color: #339933;">-</span>content <span style="color: #339933;">--&gt;</span></pre></td></tr></table></div>

<p>Delete the bottom navigation from what was once your old <code>single.php</code>, and you’re done your <code>attachment.php</code>&nbsp;Template.</p>
<h2>The 404&nbsp;Template</h2>
<p>A 404 Error is the server code for, “I can’t find this page” and it’s an event you need to take care of in your WordPress Themes. What happens when a link to your blog has a post url typed incorrectly? Or you unpublish a blog post? Your server coughs up a 404&nbsp;error.</p>
<p>Luckily, WordPress has a template for that. It’s called, <code>404.php</code>. The technique I stick with for 404 Templates is pretty straightforward but it works. Apologize and include a search form. There might be more creative solutions but none that get out of your visitor’s way&nbsp;faster.</p>
<p>Go back to your template-template above, drop the navigation and add something like this to the&nbsp;content.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189366"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p1893code66"><pre class="php" style="font-family:monospace;">				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post-0&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post error404 not-found&quot;</span><span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>h1 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-title&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Not Found'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>h1<span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-content&quot;</span><span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Apologies, but we were unable to find what you were looking for. Perhaps searching will help.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_search_form<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
					<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">.</span>entry<span style="color: #339933;">-</span>content <span style="color: #339933;">--&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#post-0 --&gt;</span></pre></td></tr></table></div>

<h2>How To Create a WordPress&nbsp;Theme</h2>
<p>This post is part of a <a href="http://themeshaper.com/wordpress-themes-templates-tutorial/">WordPress Themes Tutorial</a> that will show you how to create a powerful WordPress Theme from scratch. Read it from the beginning and code yourself up something&nbsp;awesome.</p>
<ol>
<li><a href="http://themeshaper.com/wordpress-themes-templates-tutorial/">WordPress Theme Tutorial&nbsp;Introduction</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-development-tools-tutorial/">Theme Development&nbsp;Tools</a></li>
<li><a href="http://themeshaper.com/creating-wordpress-theme-html-structure-tutorial/">Creating a Theme HTML&nbsp;Structure</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-template-directory-structure-tutorial/">Template and Directory&nbsp;Structure</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-header-template-tutorial/">The Header&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-index-template-tutorial/">The Index&nbsp;Template</a></li>
<li>The Single Post, Post Attachment, &#038; 404&nbsp;Templates</li>
<li><a href="http://themeshaper.com/wordpress-theme-comments-template-tutorial/">The Comments&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-search-page-template-tutorial/">The Search Template &#038; The Page&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/archive-author-category-tags-template/">The Archive, Author, Category &#038; Tags&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-sidebar-template/">The Sidebar&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/reset-rebuild-wordpress-theme-css-define-layouts/">Reset-Rebuild Theme CSS &#038; Define Your&nbsp;Layouts</a></li>
</ol>
Similar Posts:<ul><li><a href="http://themeshaper.com/archive-author-category-tags-template/" rel="bookmark" title="July 3, 2009">The Archive, Author, Category &#038; Tags&nbsp;Template</a></li>

<li><a href="http://themeshaper.com/wordpress-theme-index-template-tutorial/" rel="bookmark" title="June 29, 2009">The WordPress Theme Index&nbsp;Template</a></li>

<li><a href="http://themeshaper.com/wordpress-theme-template-directory-structure-tutorial/" rel="bookmark" title="June 25, 2009">WordPress Theme Template &#038; Directory&nbsp;Structure</a></li>
</ul><!-- Similar Posts took 3.831 ms --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=mwnHMx5lOGM:k4w-0WMkbGQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=mwnHMx5lOGM:k4w-0WMkbGQ:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=mwnHMx5lOGM:k4w-0WMkbGQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=mwnHMx5lOGM:k4w-0WMkbGQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=mwnHMx5lOGM:k4w-0WMkbGQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=mwnHMx5lOGM:k4w-0WMkbGQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=mwnHMx5lOGM:k4w-0WMkbGQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=mwnHMx5lOGM:k4w-0WMkbGQ:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ThemeShaper/~4/mwnHMx5lOGM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://themeshaper.com/wordpress-theme-single-post-post-attachment-404-templates-tutorial/feed/</wfw:commentRss>
		<slash:comments>45</slash:comments>
		<feedburner:origLink>http://themeshaper.com/wordpress-theme-single-post-post-attachment-404-templates-tutorial/</feedburner:origLink></item>
		<item>
		<title>The WordPress Theme Index Template</title>
		<link>http://feedproxy.google.com/~r/ThemeShaper/~3/zqtF2em4SmY/</link>
		<comments>http://themeshaper.com/wordpress-theme-index-template-tutorial/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 11:00:53 +0000</pubDate>
		<dc:creator>Ian Stewart</dc:creator>
				<category><![CDATA[Theme Tips]]></category>

		<guid isPermaLink="false">http://themeshaper.com/?p=1891</guid>
		<description><![CDATA[Index.php is the most crucial WordPress Theme Template. Not only because WordPress needs to use it if you’re missing any of it’s brother and sister templates (like, category.php or tag.php) but because the work we do here, getting this template right, will help us breeze through the rest of our templates (with the exception of [...]]]></description>
			<content:encoded><![CDATA[<p><code>Index.php</code> is the most crucial WordPress Theme Template. Not only because WordPress needs to use it if you’re missing any of it’s brother and sister templates (like, <code>category.php</code> or <code>tag.php</code>) but because the work we do here, getting this template right, will help us breeze through the rest of our templates (with the exception of the dreaded comments template; that’s just plain difficult no matter how you look at&nbsp;it).</p>
<h2>The&nbsp;Loop</h2>
<p>Even though it’s stuck right in the middle of your template, in a metaphorical sense <code>index.php</code> begins and ends with <strong>The Loop</strong>. Without it you don’t have anything. Here’s what it looks&nbsp;like.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189178"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1891code78"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Simple really. And not even deceptively simple. While you’ve got posts in your database your theme will loop through them and for each one, do something. Getting the “do something” just right is the tricky part. But even that can be&nbsp;simple.</p>
<p>Try out this loop to get started and we’ll work on building it up. Put the following code inside your #content div in&nbsp;<code>index.php</code>.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189179"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p1891code79"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>What do you get if you do that? All the post content in a big smushed up pile. But it could be&nbsp;different.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189180"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p1891code80"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;</span>
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_excerpt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>		
<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Do you see what we just did there? Now you’ve got an unordered list of post excerpts. (Plus, now you can see what <code>the_content()</code> and <code>the_excerpt()</code>&nbsp;do)</p>
<p>Basically, you make a loop (starts with <em>while</em> ends with <em>endwhile</em>) and put some stuff in it—stuff being WordPress Template Tags that pull information out of the posts we’re looping though, just like <code>bloginfo()</code> pulled information out of our WordPress settings in the last&nbsp;lesson.</p>
<p>Alright, let’s make a really awesome loop. Let’s start with our basic, smushed up one. But we’ll make sure it’s ready for the <a href="http://codex.wordpress.org/Customizing_the_Read_More">More Tag</a> and the <a href="http://codex.wordpress.org/Template_Tags/wp_link_pages">Next Page Tag</a>. We’ll also put it in it’s own div and let machines know it’s the content of a blog post with the microformat class&nbsp;“entry-content”.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189181"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p1891code81"><pre class="php" style="font-family:monospace;">					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-content&quot;</span><span style="color: #339933;">&gt;</span>	
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Continue reading &lt;span class=&quot;meta-nav&quot;&gt;&amp;raquo;&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_link_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'before=&lt;div class=&quot;page-link&quot;&gt;'</span> <span style="color: #339933;">.</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Pages:'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;after=&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
					<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">.</span>entry<span style="color: #339933;">-</span>content <span style="color: #339933;">--&gt;</span></pre></td></tr></table></div>

<p>How about the post title? That’s pretty simple too. We’ll use the Template Tag <code>the_title()</code> to get the title of the post and wrap it in an <code>&lt;a&gt;</code> tag that links to <code>the_permalink()</code> (that’s the permanent link to any particular post). We’ll also add in a title attribute and another microformat (bookmark) that tells machines (like Google) that this is the permalink to a blog post. Try putting the following just above the .entry-content&nbsp;div.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189182"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1891code82"><pre class="php" style="font-family:monospace;">					<span style="color: #339933;">&lt;</span>h2 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-title&quot;</span><span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php the_permalink(); ?&gt;&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php printf( __('Permalink to <span style="color: #009933; font-weight: bold;">%s</span>', 'your-theme'), the_title_attribute('echo=0') ); ?&gt;&quot;</span> rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;bookmark&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>h2<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Now for all the extra bits that attend to any blog post: who wrote it, the time it was published, categories, tags, comments links. I like to break all this up into two sections: the meta stuff (author and entry date) which I put before the post content, and the utility stuff (categories, tags and comments link) that I put after the content. And both sections We’ll also put the post in it’s own containing div with the&nbsp;title.</p>
<p>Let’s take a look at the whole loop together. I’ve inserted some PHP comments in here to help guide you&nbsp;along.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189183"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td class="code" id="p1891code83"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* The Loop — with comments! */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>			
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* Create a div with a unique ID thanks to the_ID() and semantic classes with post_class() */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>		
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post-&lt;?php the_ID(); ?&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;?php</span> post_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&gt;</span>				
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* an h2 title */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>							
					<span style="color: #339933;">&lt;</span>h2 <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-title&quot;</span><span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php the_permalink(); ?&gt;&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php printf( __('Permalink to <span style="color: #009933; font-weight: bold;">%s</span>', 'your-theme'), the_title_attribute('echo=0') ); ?&gt;&quot;</span> rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;bookmark&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>h2<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* Microformatted, translatable post meta */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>										
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-meta&quot;</span><span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;meta-prep meta-prep-author&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'By '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;author vcard&quot;</span><span style="color: #339933;">&gt;&lt;</span>a <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;url fn n&quot;</span> href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo get_author_link( false, <span style="color: #006699; font-weight: bold;">$authordata-&gt;ID</span>, <span style="color: #006699; font-weight: bold;">$authordata-&gt;user_nicename</span> ); ?&gt;&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php printf( __( 'View all posts by <span style="color: #009933; font-weight: bold;">%s</span>', 'your-theme' ), <span style="color: #006699; font-weight: bold;">$authordata-&gt;display_name</span> ); ?&gt;&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_author<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;meta-sep&quot;</span><span style="color: #339933;">&gt;</span> <span style="color: #339933;">|</span> <span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;meta-prep meta-prep-entry-date&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Published '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-date&quot;</span><span style="color: #339933;">&gt;&lt;</span>abbr <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;published&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php the_time('Y-m-d<span style="color: #000099; font-weight: bold;">\T</span>H:i:sO') ?&gt;&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php the_time<span style="color: #009900;">&#40;</span> get_option<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'date_format'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>abbr<span style="color: #339933;">&gt;&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #000000; font-weight: bold;">&lt;?php</span> edit_post_link<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Edit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>meta-sep<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;|&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>edit-link<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
					<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">.</span>entry<span style="color: #339933;">-</span>meta <span style="color: #339933;">--&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* The entry content */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>					
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-content&quot;</span><span style="color: #339933;">&gt;</span>	
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Continue reading &lt;span class=&quot;meta-nav&quot;&gt;&amp;raquo;&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_link_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'before=&lt;div class=&quot;page-link&quot;&gt;'</span> <span style="color: #339933;">.</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Pages:'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;after=&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
					<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #339933;">.</span>entry<span style="color: #339933;">-</span>content <span style="color: #339933;">--&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* Microformatted category and tag links along with a comments link */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>					
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-utility&quot;</span><span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cat-links&quot;</span><span style="color: #339933;">&gt;&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;entry-utility-prep entry-utility-prep-cat-links&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php _e<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Posted in '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php <span style="color: #b1b100;">echo</span> get_the_category_list<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">', '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;meta-sep&quot;</span><span style="color: #339933;">&gt;</span> <span style="color: #339933;">|</span> <span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_tags<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'&lt;span class=&quot;tag-links&quot;&gt;&lt;span class=&quot;entry-utility-prep entry-utility-prep-tag-links&quot;&gt;'</span> <span style="color: #339933;">.</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Tagged '</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>meta-sep<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;|&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
						<span style="color: #339933;">&lt;</span>span <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;comments-link&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php comments_popup_link<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Leave a comment'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'1 Comment'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'% Comments'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span>
						<span style="color: #000000; font-weight: bold;">&lt;?php</span> edit_post_link<span style="color: #009900;">&#40;</span> __<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Edit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>meta-sep<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;|&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>&lt;span class=<span style="color: #000099; font-weight: bold;">\&quot;</span>edit-link<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;/span&gt;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
					<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#entry-utility --&gt;	
</span>				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#post-&lt;?php the_ID(); </span><span style="color: #000000; font-weight: bold;">?&gt;</span> <span style="color: #339933;">--&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* Close up the post div and then end the loop with endwhile */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>		
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h2>Navigation</h2>
<p>Now we need a way to navigate back through our posts. We’ll do this with 2 WordPress Template Tags: <code>next_posts_link()</code> and <code>previous_posts_link()</code>. These 2 functions … they don’t do what you think they do. I think the WordPress codex says it&nbsp;best.</p>
<blockquote><dl>
<dt>next posts link</dt>
<dd>This creates a link to the previous posts. Yes, it says &#8220;next posts,&#8221; but it&#8217;s named that just to confuse you.</dd>
<dt>previous posts link</dt>
<dd>This creates a link to the next posts. Yes, it says &#8220;previous posts,&#8221; but it&#8217;s named that just to confuse you.</dd>
</dl>
</blockquote>
<p>Just like everything in <code>index.php</code>, post navigation needs to be given some careful thought when we’re building it for the first time because we’re going to wind up using it on almost every page in our&nbsp;blog.</p>
<p>I like to have post navigation above and below the content. Depending on how you use this code in any particular situation, you may not use it though. No matter, we can always hide it like&nbsp;so.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189184"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p1891code84"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.single</span> <span style="color: #cc00cc;">#nav-</span><span style="color: #993333;">above</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>That CSS will hide post navigation <strong>above</strong> the content on <strong>single</strong>&nbsp;posts.</p>
<p>We’ll also want to hide any navigation code IF there’s nothing to navigate too. That is, if, say, on a search, there are no older pages of posts, we don’t want to output any navigation code at all to the browser. We’ll do that by wrapping our code in the following&nbsp;statement:</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189185"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p1891code85"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">;</span> <span style="color: #000088;">$total_pages</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">max_num_pages</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$total_pages</span> <span style="color: #339933;">&gt;</span> 1 <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>What we’re doing is checking to see what the maximum number of pages is in any loop we’re going to be looking at and if the number of pages is greater than 1, we’ll output our&nbsp;navigation.</p>
<p>Alright, here’s the code we’ll need for your navigation, top and bottom, just before, and just after the&nbsp;loop.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189186"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p1891code86"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* Top post navigation */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">;</span> <span style="color: #000088;">$total_pages</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">max_num_pages</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$total_pages</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-above&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;navigation&quot;</span><span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-previous&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php next_posts_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'&lt;span class=&quot;meta-nav&quot;&gt;&amp;laquo;&lt;/span&gt; Older posts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-next&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php previous_posts_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Newer posts &lt;span class=&quot;meta-nav&quot;&gt;&amp;raquo;&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#nav-above --&gt;
</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<div class="wp_codebox"><table width="100%" ><tr id="p189187"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p1891code87"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* Bottom post navigation */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">;</span> <span style="color: #000088;">$total_pages</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">max_num_pages</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$total_pages</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
				<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-below&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;navigation&quot;</span><span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-previous&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php next_posts_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'&lt;span class=&quot;meta-nav&quot;&gt;&amp;laquo;&lt;/span&gt; Older posts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
					<span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nav-next&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?</span>php previous_posts_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Newer posts &lt;span class=&quot;meta-nav&quot;&gt;&amp;raquo;&lt;/span&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'your-theme'</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
				<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;!--</span> <span style="color: #666666; font-style: italic;">#nav-below --&gt;
</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>One last thing and we’re done <code>index.php</code>. You’ll be itching to see what we can do with it, but for now we’re just going to put in the function call just before&nbsp;<code>get_footer()</code>.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p189188"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1891code88"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> get_sidebar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h2>How To Create a WordPress&nbsp;Theme</h2>
<p>This post is part of a <a href="http://themeshaper.com/wordpress-themes-templates-tutorial/">WordPress Themes Tutorial</a> that will show you how to create a powerful WordPress Theme from scratch. Read it from the beginning and code yourself up something&nbsp;awesome.</p>
<ol>
<li><a href="http://themeshaper.com/wordpress-themes-templates-tutorial/">WordPress Theme Tutorial&nbsp;Introduction</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-development-tools-tutorial/">Theme Development&nbsp;Tools</a></li>
<li><a href="http://themeshaper.com/creating-wordpress-theme-html-structure-tutorial/">Creating a Theme HTML&nbsp;Structure</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-template-directory-structure-tutorial/">Template and Directory&nbsp;Structure</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-header-template-tutorial/">The Header&nbsp;Template</a></li>
<li>The Index&nbsp;Template</li>
<li><a href="http://themeshaper.com/wordpress-theme-single-post-post-attachment-404-templates-tutorial/">The Single Post, Post Attachment, &#038; 404&nbsp;Templates</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-comments-template-tutorial/">The Comments&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-search-page-template-tutorial/">The Search Template &#038; The Page&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/archive-author-category-tags-template/">The Archive, Author, Category &#038; Tags&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/wordpress-theme-sidebar-template/">The Sidebar&nbsp;Template</a></li>
<li><a href="http://themeshaper.com/reset-rebuild-wordpress-theme-css-define-layouts/">Reset-Rebuild Theme CSS &#038; Define Your&nbsp;Layouts</a></li>
</ol>
Similar Posts:<ul><li><a href="http://themeshaper.com/wordpress-theme-single-post-post-attachment-404-templates-tutorial/" rel="bookmark" title="June 30, 2009">The WordPress Theme Single Post, Post Attachment, &#038; 404&nbsp;Templates</a></li>

<li><a href="http://themeshaper.com/archive-author-category-tags-template/" rel="bookmark" title="July 3, 2009">The Archive, Author, Category &#038; Tags&nbsp;Template</a></li>

<li><a href="http://themeshaper.com/wordpress-theme-template-directory-structure-tutorial/" rel="bookmark" title="June 25, 2009">WordPress Theme Template &#038; Directory&nbsp;Structure</a></li>
</ul><!-- Similar Posts took 3.975 ms --><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=zqtF2em4SmY:m_6hOKoPH5U:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=zqtF2em4SmY:m_6hOKoPH5U:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=zqtF2em4SmY:m_6hOKoPH5U:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=zqtF2em4SmY:m_6hOKoPH5U:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=zqtF2em4SmY:m_6hOKoPH5U:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=zqtF2em4SmY:m_6hOKoPH5U:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/ThemeShaper?a=zqtF2em4SmY:m_6hOKoPH5U:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/ThemeShaper?i=zqtF2em4SmY:m_6hOKoPH5U:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/ThemeShaper/~4/zqtF2em4SmY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://themeshaper.com/wordpress-theme-index-template-tutorial/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		<feedburner:origLink>http://themeshaper.com/wordpress-theme-index-template-tutorial/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 10.741 seconds. --><!-- Cached page generated by WP-Super-Cache on 2009-11-08 01:39:22 --><!-- Compression = gzip -->
