<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" 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/" ><channel><title>WPShout.com &#187; Theme Design</title> <atom:link href="http://wpshout.com/category/themes/feed/" rel="self" type="application/rss+xml" /><link>http://wpshout.com</link> <description>WordPress Tutorials</description> <lastBuildDate>Wed, 01 Feb 2012 21:03:25 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <item><title>Really Easy Custom Post Backgrounds For WordPress</title><link>http://wpshout.com/wordpress-custom-post-backgrounds/</link> <comments>http://wpshout.com/wordpress-custom-post-backgrounds/#comments</comments> <pubDate>Tue, 22 Jun 2010 16:26:24 +0000</pubDate> <dc:creator>Alex Denning</dc:creator> <category><![CDATA[Art Direction]]></category> <category><![CDATA[Custom Fields]]></category><guid isPermaLink="false">http://wpshout.com/?p=2376</guid> <description><![CDATA[<p><p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/wordpress-custom-post-backgrounds/">Really Easy Custom Post Backgrounds For WordPress</a></p></p><p>As I mentioned before, I've been having great fun with the new Nometet.com design. It's now sporting a feature that allows the author to set a custom background for the post just by uploading an image. This image doesn't even need to be the correct size; that's all done on the fly. Uploading isn't hard either; I've implemented an uploader that sits inside a meta box so the hardest bit is choosing the image! In this post we'll have a look at how it's done.</p></p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/wordpress-custom-post-backgrounds/">Really Easy Custom Post Backgrounds For WordPress</a></p></p>]]></description> <content:encoded><![CDATA[<p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/wordpress-custom-post-backgrounds/">Really Easy Custom Post Backgrounds For WordPress</a></p></p><p>As I&#8217;ve mentioned before, I&#8217;ve been having great fun with the new <a href="http://nometet.com">Nometet.com</a> design. It&#8217;s now sporting a feature that allows the author to set a custom background for the post just by uploading an image. This image doesn&#8217;t even need to be the correct size; that&#8217;s all done on the fly. Uploading isn&#8217;t hard either; I&#8217;ve implemented an uploader that sits inside a meta box so the hardest bit is choosing the image! In this post we&#8217;ll have a look at how it&#8217;s done.</p><p>The uploader we&#8217;re going to be using later saves the image URL to a custom field, so first we&#8217;re going to get the custom field set up so that all you have to do is input a URL into the custom field and it gets displayed as the background. As I&#8217;ve shown before, it&#8217;s fairly easy:</p><pre><code>&lt;?php
$bg = get_post_custom_values("background");
if ( is_array($bg) ) { ?&gt;

&lt;style type="text/css" media="screen"&gt;

body{ background: url(&lt;?php echo $bg ?&gt;) fixed no-repeat; }

&lt;/style&gt;

&lt;?php } ?&gt;</code></pre><p>But that still means you&#8217;ve got to resize the image and copy out the URL into a custom field.</p><h2>Custom meta uploader</h2><p>We need an uploader in a meta box. When I was first pondering how to do this, I remembered that <a href="http://wpshout.com/go/woothemes/ "target="_blank"title="" >WooThemes</a> use(d to use?) them in their themes. So I opened up one and lo and behold, there was a file <code>admin-custom.php</code> (under /functions). This is the bit used for the uploader and other custom meta boxes.</p><p><a href="http://wpshout.wpcdn.com/media/2010/04/custom-uploader.jpg"><img class="alignnone size-full wp-image-2390" title="custom-uploader" src="http://wpshout.wpcdn.com/media/2010/04/custom-uploader.jpg" alt="" width="590" height="200" /></a></p><p>At this point I got slightly confused &#8211; at the top of the file it says:</p><p>This code is protected under Creative Commons License: http://creativecommons.org/licenses/by-nc-nd/3.0/</p><p>Which is completely contradictory to Woo being GPL and as the file is dependant on WordPress, I&#8217;m fairly sure it needs to be GPL too. Either way, as I see it I can still publish the code here. To be totally safe, I&#8217;m not going to &#8220;alter, transform, or build upon this work&#8221;. This does mean we&#8217;ve got some code we don&#8217;t strictly need, but it won&#8217;t have too much of a disastrous effect!</p><p><em>As it&#8217;s a fairly big file, you can download it </em><a href="http://wpshout.wpcdn.com/media/2010/04/admin-custom.txt"><em>here</em></a><em>.</em></p><p>Once you&#8217;ve got the file, copy the whole thing into your functions.php file, making sure it goes <em>directly after</em> the closing <code>?&gt;</code> tag (ie ?<code>&gt;&lt;?php</code> ).</p><p>We then need to trigger the meta box, which can be done with the following:</p><pre><code>$woo_metaboxes = array(

		"image" =&gt; array (
			"name"		=&gt; "bg",
			"label" 	=&gt; "Background",
            "type" =&gt; "upload",
			"desc"      =&gt; "Automatically resized/enlarged but at least 1000px x 800px for it to be big enough."
		),

	);

update_option('woo_custom_template',$woo_metaboxes);   </code></pre><p>Add that after the other code, but before the closing <code>?&gt;</code> tag. Save the file, upload it and create a new post. You&#8217;ve now got an uploader which will save images into the custom field &#8216;bg&#8217;.</p><h2>Resizing the images</h2><p><a href="http://wpshout.wpcdn.com/media/2010/04/custom-bg.jpg"><img class="alignnone size-full wp-image-2393" title="custom-bg" src="http://wpshout.wpcdn.com/media/2010/04/custom-bg.jpg" alt="" width="590" height="300" /></a></p><p>The final thing to do now is to just use timthumb to resize the images to a width of 1920px. Simple enough; download <a href="http://code.google.com/p/timthumb/">timthumb</a>, upload it into your theme&#8217;s files and just apply the timbthumb syntax to the code in the header:</p><pre><code>
body{
background: url(&lt;?php bloginfo('template_url'); ?&gt;/tools/timthumb.php?w=1920&amp;zc=1&amp;src=&lt;?php echo $bg; ?&gt;) fixed no-repeat;
}

</code></pre><p>And as you can see, that&#8230; doesn&#8217;t work. The custom field adds http://&#8230; to the image URL which timthumb doesn&#8217;t like.</p><p>At this point, I pondered a bit, tried (and failed) at a couple of solutions so did the only thing I could; grovelled with <a href="http://binarymoon.co.uk">Ben </a>to give me a hand. Thankfully, he agreed and told me I needed to encode my URLs, which means you&#8217;ll need to change the code to this:</p><pre><code>body{
background: url(&lt;?php bloginfo('template_url'); ?&gt;/tools/timthumb.php?w=1920&amp;zc=1&amp;src=&lt;?php echo urlencode($bg); ?&gt;) fixed no-repeat;
}</code></pre><h2>And finally</h2><p>Which leaves us with a really easy to use custom background uploader. You can check it out in action on the new look <a href="http://nometet.com">Nometet</a>! Speaking of which, I&#8217;d really appreciate it if you gave the site a look; it&#8217;s a web based video game magazine.</p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/wordpress-custom-post-backgrounds/">Really Easy Custom Post Backgrounds For WordPress</a></p></p>]]></content:encoded> <wfw:commentRss>http://wpshout.com/wordpress-custom-post-backgrounds/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Art Direction For WordPress</title><link>http://wpshout.com/art-direction-wordpress/</link> <comments>http://wpshout.com/art-direction-wordpress/#comments</comments> <pubDate>Mon, 07 Jun 2010 14:00:42 +0000</pubDate> <dc:creator>Alex Denning</dc:creator> <category><![CDATA[Art Direction]]></category><guid isPermaLink="false">http://wpshout.com/?p=2940</guid> <description><![CDATA[<p><p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/art-direction-wordpress/">Art Direction For WordPress</a></p></p><p>"Art direction", custom post designs, whatever you want to call them have taken off in a big way recently. First it was Jason Santa Maria amongst others, then Smashing Magazine picked up on it and as a trend it exploded. For good reason too; they're awesome and great fun to do. In this post we'll see how art direction and WordPress can be combined to create something awesome.</p></p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/art-direction-wordpress/">Art Direction For WordPress</a></p></p>]]></description> <content:encoded><![CDATA[<p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/art-direction-wordpress/">Art Direction For WordPress</a></p></p><p><img src="http://wpshout.wpcdn.com/media/2010/06/art-going.png" alt="" title="art-going" width="500" height="500" class="alignnone size-full wp-image-2960" /></p><p>&#8220;<a href="http://wpshout.com/art-direction-wordpress/"target="_blank"title="WordPress Art Direction" >Art direction</a>&#8220;, custom post designs, whatever you want to call them have taken off in a big way recently. First it was <a href="http://jasonsantamaria.com">Jason Santa Maria</a> amongst others, then Smashing Magazine <a href="http://www.smashingmagazine.com/the-death-of-the-blog-post/">picked up on it</a> and as a trend<br /> it exploded. For good reason too;<br /> they&#8217;re awesome and great fun to do.</p><p>My personal favourites are the ones on <a href="http://designinformer.com/grid-based-web-design-simplified/">Design Informer</a> and <a href="http://www.binarymoon.co.uk/category/general/art-direction/">Binary Moon</a>. Both, like WPShout, are powered by WordPress. Unlike WPShout, they&#8217;re using custom post templates, something I&#8217;ve found myself increasingly against as<br /> they&#8217;re a pain once you change the design. <br /> Sure, no way&#8217;s going to be perfect once you change a design, but some ways are<br /> less of a pain than others.</p><p>Art direction is awesome and enhances your blog no end.</p><p>Here on WPShout I&#8217;m using <em>CSS exclusively</em>. This means the HTML doesn&#8217;t change one bit between non art directed posts and art directed posts; I just use a custom field to add in an extra stylesheet. When I first started dabbling in art direction a couple of months ago I found myself using inline styles through custom fields, but quickly realised <em>that sucks</em> because you can&#8217;t easily reuse the styles (find styles from last time, find file on FTP, load into text editor and so on) <em>and</em>, crucially, you can&#8217;t <em>gracefully degrade</em> your posts; the WPShout layout is over 1024px, thus visitors with that screen size just get the standard layout which, although still larger than 1024px, crucially the content area isn&#8217;t so posts are still readable. With external stylesheets I can selectively apply them and make new art directed posts quicker.</p><p>Using my CSS only way, it&#8217;s<br /> <span>fairly easy</span><br /> to get started.</p><div class="caption"><img src="http://wpshout.wpcdn.com/media/2010/06/unedited-art.jpg" alt="" title="unedited-art" width="400" height="243" class="alignnone size-full wp-image-2953" /><p>My &#8220;blank canvas&#8221; for WPShout</p></div><p>The three key rules of art.</p><p><span>1.</span> I find that writing a post <em>with the design in mind</em> just doesn&#8217;t work. I have to write the post first and then fiddle around with the design. If you write trying to work out how you&#8217;ll style it, you&#8217;ll never get anything written.</p><p><span>2.</span> Next, a simple reset of a couple of styles is a godsend. I&#8217;ve got a couple of styles I use as a reset and immediately my content area gets set to full width on a white background and pushes the sidebar down to level with the start of the comments. I&#8217;ve found keeping the header, sidebar, comments and footer just adds that extra bit of consistency which is important.</p><p><span>3.</span> Finally, go <em>crazy nuts</em> with all the stuff you know is bad &#8212; use negative margins and a whole load of divs like there&#8217;s no tomorrow but crucially if you get rid of the stylesheet, everything goes back to normal and so you&#8217;re future proofed against any theme changes you make in the future.</p><div id="art-wp"><img src="http://wpshout.wpcdn.com/media/2010/06/wp-art1.jpg" alt="" title="wp-art" width="1190" height="100" class="left" /></div><h2>The <span>WordPress-ifying</span> bit</h2><p>As you might have been able to guess, we&#8217;re going to use custom fields to add our stylesheet to the post.</p><p>First thing to do is to upload the stylesheet &#8212; you&#8217;ll probably want it in your theme&#8217;s directory. Copy and paste the URL into a custom field &#8220;CSS&#8221;.</p><p>Next, pop open the header.php file and add the following, after your standard stylesheet:</p><div class="geshi no php"><ol><li class="li1"><div class="de1"><span class="kw2">&lt;?php</span> <span class="kw1">if</span> <span class="br0">&#40;</span>is_single<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="re1">$css</span> <span class="sy0">=</span> get_post_meta<span class="br0">&#40;</span><span class="re1">$post</span><span class="sy0">-&gt;</span><span class="me1">ID</span><span class="sy0">,</span> <span class="st0">&#39;css&#39;</span><span class="sy0">,</span> <span class="kw2">true</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re1">$css</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw2">?&gt;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="sy0">&lt;</span>link type<span class="sy0">=</span><span class="st0">&quot;text/css&quot;</span> rel<span class="sy0">=</span><span class="st0">&quot;stylesheet&quot;</span> media<span class="sy0">=</span><span class="st0">&#39;screen&#39;</span> href<span class="sy0">=</span><span class="st0">&quot;&lt;?php echo $css; ?&gt;&quot;</span> <span class="sy0">/&gt;</span></div></li><li class="li1"><div class="de1">&nbsp;</div></li><li class="li1"><div class="de1"><span class="kw2">&lt;?php</span> <span class="br0">&#125;</span> <span class="br0">&#125;</span> <span class="kw2">?&gt;</span></div></li></ol></div><p>Here we&#8217;re assuming your theme makes the fairly standard (in more recent themes) step of running the loop to get various titles or tags for SEO, but if it doesn&#8217;t then you can either run the loop or get custom fields <a href="http://www.wprecipes.com/wordpress-how-to-get-custom-fields-outside-the-loop">outside the loop</a> (thanks <a href="http://themelab.com">@ThemeLab</a> and <a href="http://www.mushive.com/">@mus_hi</a>).</p><h2>The <span>designing</span> bit</h2><p>So now you&#8217;ve written the post and loaded the stylesheet, the next step is to actually fill that stylesheet. I&#8217;ve found the nth-of-type pseudo selector to be a fantastic way round of wrapping each paragraph in a div &#8212; you want to float the third paragraph right so instead of using the HTML editor to add a div around the paragraph, you can instead do this:</p><div class="center"><div class="geshi no css"><ol><li class="li1"><div class="de1"><span class="re1">.hentry</span> p<span class="re2">:nth-of-type</span><span class="br0">&#40;</span><span class="nu0">3</span><span class="br0">&#41;</span><span class="br0">&#123;</span> float<span class="re2">:right</span><span class="sy0">;</span> <span class="br0">&#125;</span></div></li></ol></div></div><p>Bear in mind that if you&#8217;ve got some meta information first, that might mean the third paragraph of post content is actually the fourth paragraph within the hentry div.</p><p>And then you&#8217;re off. It&#8217;s great fun just fiddling around with styles to get your content laid out in a unique way.</p><h2>It&#8217;s that simple</h2><p>It&#8217;s taken me a while to actually see how easy it is to &#8220;art direct&#8221; my posts, but with a simple reset and adding stylesheets easily through custom fields, it&#8217;s fantastic fun just playing around and making a unique experience for your readers. Go on, give it a try.</p><p><em>Icons by <a href="http://www.phoenixheart.net/">phenixheart</a> and <a href="http://www.olawolska.com/">Olwaolska</a></em></p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/art-direction-wordpress/">Art Direction For WordPress</a></p></p>]]></content:encoded> <wfw:commentRss>http://wpshout.com/art-direction-wordpress/feed/</wfw:commentRss> <slash:comments>24</slash:comments> </item> <item><title>Change CSS Styles with Different Categories in WordPress</title><link>http://wpshout.com/change-css-styles-with-different-categories-in-wordpress/</link> <comments>http://wpshout.com/change-css-styles-with-different-categories-in-wordpress/#comments</comments> <pubDate>Wed, 10 Feb 2010 19:54:52 +0000</pubDate> <dc:creator>Alex Denning</dc:creator> <category><![CDATA[Art Direction]]></category><guid isPermaLink="false">http://wpshout.com/?p=2172</guid> <description><![CDATA[<p><p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/change-css-styles-with-different-categories-in-wordpress/">Change CSS Styles with Different Categories in WordPress</a></p></p><p>A very neat trick that allows you to apply a different stylesheet to each category (and therefore change colors), all with the power of WordPress.</p></p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/change-css-styles-with-different-categories-in-wordpress/">Change CSS Styles with Different Categories in WordPress</a></p></p>]]></description> <content:encoded><![CDATA[<p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/change-css-styles-with-different-categories-in-wordpress/">Change CSS Styles with Different Categories in WordPress</a></p></p><h2>THE PROBLEM</h2><p>Recently I needed to set up WordPress to change the background colour of the page with each parent category. After a bit of Googleing, it appeared no-one had an easy answer, so I turned to my good friend the if statement. I thought I&#8217;d combine an if statement with the WordPress template tag <a href="http://codex.wordpress.org/Function_Reference/is_category">IS_CATEGORY</a>. Soon turned out that that wasn&#8217;t an option; theis_category template tag only works for archive pages, not posts themselves.</p><h2>THE SOLUTION</h2><p>The solution was another template tag, <a href="http://codex.wordpress.org/Function_Reference/in_category">IN_CATEGORY</a>. Combine that with a number of different CSS files, each with a different colour, and I was left with the following:</p><pre><code>&lt;link rel="stylesheet" href="&lt;?php bloginfo('template_url')?&gt;/blue.css" type="text/css" media="screen,projection" /&gt;

&lt;?php
if( in_category( 1 ) )
{
?&gt;
&lt;link rel="stylesheet" href="&lt;?php bloginfo('template_url')?&gt;/blue.css" type="text/css" media="screen" /&gt;	

&lt;?php } elseif ( in_category (2) )
{
?&gt;
&lt;link rel="stylesheet" href="&lt;?php bloginfo('template_url')?&gt;/yellow.css" type="text/css" media="screen" /&gt;

&lt;?php } elseif ( in_category (33) )
{
?&gt;
&lt;link rel="stylesheet" href="&lt;?php bloginfo('template_url')?&gt;/black.css" type="text/css" media="screen" /&gt;
&lt;?php }	else { 	?&gt;

&lt;?php }	?&gt;
</code></pre><p>And that&#8217;s it. Obviously, you&#8217;ll need to put the code in the header.php file and have these different stylesheets created, but other than that, done!</p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/change-css-styles-with-different-categories-in-wordpress/">Change CSS Styles with Different Categories in WordPress</a></p></p>]]></content:encoded> <wfw:commentRss>http://wpshout.com/change-css-styles-with-different-categories-in-wordpress/feed/</wfw:commentRss> <slash:comments>9</slash:comments> </item> <item><title>Best Practices for Creating Unique Blog Posts</title><link>http://wpshout.com/best-practices-for-creating-unique-blog-posts/</link> <comments>http://wpshout.com/best-practices-for-creating-unique-blog-posts/#comments</comments> <pubDate>Wed, 27 Jan 2010 17:34:57 +0000</pubDate> <dc:creator>Alex Denning</dc:creator> <category><![CDATA[Art Direction]]></category> <category><![CDATA[Unique Post Design]]></category><guid isPermaLink="false">http://wpshout.com/?p=1643</guid> <description><![CDATA[<p><p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/best-practices-for-creating-unique-blog-posts/">Best Practices for Creating Unique Blog Posts</a></p></p><p>Recently here on WPShout I've been sharing little tips that will help create a unique look for individual blog posts. Today we'll be rounding up the "best practices" for creating that unique look, the easy way.</p></p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/best-practices-for-creating-unique-blog-posts/">Best Practices for Creating Unique Blog Posts</a></p></p>]]></description> <content:encoded><![CDATA[<p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/best-practices-for-creating-unique-blog-posts/">Best Practices for Creating Unique Blog Posts</a></p></p><p>Recently here on <a href="http://wpshout.com">WPShout</a> I&#8217;ve been sharing little tips that will help create a unique look for individual blog posts. Today we&#8217;ll be rounding up the &#8220;best practices&#8221; for creating that unique look, <em>the easy way</em>.</p><h2>Post templates</h2><p>Getting rid of the sidebar is a simple way to expand your options. Were we using pages, it would be easy to get rid of the sidebar with a page template, but those don&#8217;t exist for posts, do they? Wrong. They do. You just need <a href="http://www.nathanrice.net/plugins/single-post-template/">a plugin</a> which gives you page-like options for choosing your post template:</p><pre><code>&lt;?php
/*
Single Post Template: Template Name
Description: This part is optional, but helpful for describing the Post Template
*/
?&gt;</code></pre><p>And then with some simple styling you can widen your content area and get rid of the sidebar, offering you more room to create an awesome post.</p><h2>Multiple sidebars</h2><p>Say you don&#8217;t want to get rid of the sidebar, but instead display a <em>different</em> sidebar. That&#8217;s easy if you do multiple sidebars <em><a href="http://wpshout.com/multiple-sidebars-the-right-way-in-wordpress/">the right way</a>, </em>which, of course, has the following syntax:</p><ul><li>Save new sidebars with the sidebar-<em>name</em>.php format.</li><li>Use <code>&lt;?php get_sidebar(); ?&gt;</code> to display new sidebars:<code> &lt;?php get_sidebar('name'); ?&gt;</code></li></ul><p>You can then create a page template with your different combinations of sidebar and make that blog post just <em>that bit more</em> unique.</p><h2>Unique titles</h2><p>Image replacement, emphasis, bold, the lot are all possible thanks to custom fields. Expanding further on <a href="http://wpshout.com/awesome-wordpress-seo-with-custom-fields/">this post</a>, unique titles <em>with image replacement</em> are really easy to do. You just need to create a custom field called &#8220;post-title&#8221; and then you can put into that any kind of HTML you like &#8211; perhaps an image or just some emphasis? It&#8217;s all easy to do; you&#8217;ll need to replace &lt;?php the_title(); ?&gt; with the following code which will search for a custom field, display it if it exists and then fall back on the title.</p><pre><code>&lt;?php
$postitle = get_post_custom_values("post-title");
if ( is_array($postitle) ) { ?&gt;
&lt;?php echo get_post_meta($post-&gt;ID, "post-title", true); ?&gt;
&lt;?php }	else { ?&gt;
&lt;?php the_title(); ?&gt;
&lt;?php } ?&gt;</code></pre><p>Remember that custom fields can hold <em>any</em> kind of information and so you can put whatever you like in them to be displayed as the title &#8211; an image, some emphasis or just some text; do <em>whatever you like</em>.</p><h2>Inline styling</h2><p>Custom fields to the rescue again; we can use custom fields to add some simple styling to any post. As we&#8217;re outside of the loop, we&#8217;ll need some extra code, but nothing too complicated:</p><p>&lt;?php $css = get_post_meta($post-&gt;ID, &#8216;css&#8217;, true); ?&gt;</p><p>Needs to go at the top of your header file and then below your stylesheet, you&#8217;ll need the following:</p><pre><code>&lt;?php echo $css; ?&gt;
</code></pre><p>And then you can fill in your custom field with some inline styling and perhaps change the background:</p><pre><code>&lt;style type="text/css" media="screen"&gt;

body{ background: #fff; }

&lt;/style&gt;<span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: small;"><span style="line-height: 19px; white-space: normal;">
</span></span></code></pre><h2>Create columns of text <em>within the post</em></h2><p>This is probably my favourite. Using a simple grid system, it&#8217;s possible to put your content into many columns. <a href="http://wpshout.com/the-death-of-the-boring-blog-post-easily-add-columns-to-any-wordpress-post/">This post</a> explains all. You may ask why you don&#8217;t just use a &lt;p class=&#8221;grid1&#8243;&gt;-like system. The answer is that WordPress automatically adds in the &lt;p&gt; tag, so the only real option is to use &lt;div&gt;s.</p><h2>Concluding</h2><p>So there we have a number of ways to create a really fantastic unique blog post. Go and reap the rewards!</p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/best-practices-for-creating-unique-blog-posts/">Best Practices for Creating Unique Blog Posts</a></p></p>]]></content:encoded> <wfw:commentRss>http://wpshout.com/best-practices-for-creating-unique-blog-posts/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>The Death of the Boring Blog Post &#8211; Easily Add Columns to Any WordPress Post</title><link>http://wpshout.com/the-death-of-the-boring-blog-post-easily-add-columns-to-any-wordpress-post/</link> <comments>http://wpshout.com/the-death-of-the-boring-blog-post-easily-add-columns-to-any-wordpress-post/#comments</comments> <pubDate>Thu, 26 Nov 2009 12:00:35 +0000</pubDate> <dc:creator>Alex Denning</dc:creator> <category><![CDATA[Art Direction]]></category><guid isPermaLink="false">http://wpshout.com/?p=1634</guid> <description><![CDATA[<p><p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/the-death-of-the-boring-blog-post-easily-add-columns-to-any-wordpress-post/">The Death of the Boring Blog Post &#8211; Easily Add Columns to Any WordPress Post</a></p></p><p>Easily put your post's content into columns using just the WordPress text editor and a CSS grid.</p></p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/the-death-of-the-boring-blog-post-easily-add-columns-to-any-wordpress-post/">The Death of the Boring Blog Post &#8211; Easily Add Columns to Any WordPress Post</a></p></p>]]></description> <content:encoded><![CDATA[<p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/the-death-of-the-boring-blog-post-easily-add-columns-to-any-wordpress-post/">The Death of the Boring Blog Post &#8211; Easily Add Columns to Any WordPress Post</a></p></p><p>Smashing Magazine recently published a wonderful post &#8220;The Death of the Boring Blog Post&#8221; which touches more or less on what I shared the other day &#8211; multiple post templates. Today we&#8217;re going to expand on that tutorial (except this is the really easy way).<br /> It was watching <a href="http://net.tutsplus.com/videos/screencasts/5-more-helpful-video-quick-tips/">a screencast on Nettuts</a> the other day that inspired this post. Jeffrey Way was showing how to change the background of a post with custom fields (which is yet another example of the brilliance of the things!) when he shows a demo on his personal test area. The test area is a framework called &#8220;Flexible-WP&#8221;. I have no idea what it&#8217;s designed to do, but looking at <a href="http://tests.jeffrey-way.com/flexible-wp/?p=1">a post</a>, this is a pretty neat idea. Set some styling and use divs <em>within posts</em> to put posts into columns.<br /> Here&#8217;s an example. Jeffrey has <a href="http://tests.jeffrey-way.com/flexible-wp/wp-content/themes/flexible-wp/style.css">a grid</a>. This grid can then be applied within posts just by going into the HTML editor in WordPress and adding a div around some text:-</p><pre><code>
<div class="g4">A paragraph of interesting text.</div>
<div class="g4">A paragraph of more interesting text.</div>

</code></pre><p>And then you&#8217;d have two bits of text which would be in columns next to each other. Clever, no?</p><p><img class="alignnone" src="/wp-content/uploads/images/ysswtt.png" alt="" width="482" height="495" /></p><h2>Implementation</h2><p>Implementation of this is actually quite simple. You&#8217;ll need a grid. If you&#8217;re using a theme based on a framework, it&#8217;s quite probably got the 960 grid system built in, in which case you can use that. If not, open up your style.css file and either create your own or use something similar to the below which Jeffrey uses on his site:</p><pre><code>.g1 { width: 60px; margin-left: 10px; margin-right: 10px; float: left; display: inline; }
.g2 { width: 140px; margin-left: 10px; margin-right: 10px; float: left; display: inline; }
.g3 { width: 220px; margin-left: 10px; margin-right: 10px; float: left; display: inline;}
.g4 { width: 300px; margin-left: 10px; margin-right: 10px; float: left; display: inline; }
.g5 { width: 380px; margin-left: 10px; margin-right: 10px; float: left; display: inline; }
.g6 { width: 460px; margin-left: 10px; margin-right: 10px; margin-bottom: 20px; float: left; display: inline; }
.g7 { width: 540px; margin-left: 10px; margin-right: 10px; float: left; display: inline; }
.g8 { width: 620px; margin-left: 10px; margin-right: 10px; float: left; display: inline; }
.g9 { width: 700px; margin-left: 10px; margin-right: 10px; margin-bottom: 20px; float: left; display: inline; }
.g10 { width: 780px; margin-left: 10px; margin-right: 10px; float: left; display: inline; }
.g11 { width: 860px; margin-left: 10px; margin-right: 10px; float: left; display: inline; }
.g12 { width: 940px; margin-left: 10px; margin-right: 10px; float: left; display: inline; }</code></pre><p>And then when writing, you can utilise your grid by wrapping text as I show above. A really easy (and effective) to make your blog post <em>that </em>bit more unique and exciting.</p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/the-death-of-the-boring-blog-post-easily-add-columns-to-any-wordpress-post/">The Death of the Boring Blog Post &#8211; Easily Add Columns to Any WordPress Post</a></p></p>]]></content:encoded> <wfw:commentRss>http://wpshout.com/the-death-of-the-boring-blog-post-easily-add-columns-to-any-wordpress-post/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>Single Post Templates Made Easy</title><link>http://wpshout.com/single-post-templates-made-easy/</link> <comments>http://wpshout.com/single-post-templates-made-easy/#comments</comments> <pubDate>Mon, 09 Nov 2009 12:00:37 +0000</pubDate> <dc:creator>Alex Denning</dc:creator> <category><![CDATA[Art Direction]]></category><guid isPermaLink="false">http://wpshout.com/?p=1602</guid> <description><![CDATA[<p><p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/single-post-templates-made-easy/">Single Post Templates Made Easy</a></p></p><p>Create really awesome custom post templates for WordPress with a simple (theme integrate-able) plugin.</p></p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/single-post-templates-made-easy/">Single Post Templates Made Easy</a></p></p>]]></description> <content:encoded><![CDATA[<p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/single-post-templates-made-easy/">Single Post Templates Made Easy</a></p></p><p>I had the visual pleasure of reading Ben Gillbanks&#8217; blog, <a href="http://binarymoon.co.uk">BinaryMoon </a>the other day. Whilst Ben&#8217;s blog is usually looking pretty darn good, using <a href="http://wpshout.com/advanced-uses-of-wordpress-cms-tumblelogs-reviews-and-podcasting/">WordPress as an advanced blogging platform</a>, the other day it looked particularly good. Why? Ben was using unique page templates<a href="http://www.binarymoon.co.uk/2009/11/coraline-itunes-movie-review/"> for specific blog posts</a>.</p><p><a href="http://wpshout.wpcdn.com/media/2009/11/normal-vs.jpg"><img class="alignnone size-full wp-image-1603" title="normal-vs" src="http://wpshout.wpcdn.com/media/2009/11/normal-vs.jpg" alt="normal-vs" width="590" height="300" /></a></p><p>I immediately thought to myself: &#8220;I need to know how to do that.&#8221; So <a href="http://www.binarymoon.co.uk/2009/11/up-disney-pixar-movie-review/comment-page-1/#comment-22684">I found out</a>. Looks like <a href="http://prothemedesign.com/themes/elemental/">Elemental </a>is using some rather like Nathan Rice&#8217;s <a href="http://www.nathanrice.net/plugins/single-post-template/">post template plugin</a> which adds a simple dropdown to the post editor offering different post templates.</p><p><img class="alignnone" src="http://wpshout.com/wp-content/uploads/images/zxs1tl.png" alt="" width="593" height="141" /></p><p>As themes and plugins start to merge more and more these days, this is yet another example of the merging that&#8217;s taking place &#8211; to integrate post templates into a theme is really easy:- download and unzip the plugin, open the php file and copy and paste into your functions.php file (at the very bottom, after closing php tag; you&#8217;ll want to tidy it up later one you&#8217;ve decided you&#8217;ll keep it). Next, you need to create the page template &#8211; create a duplicate of your single.php file but add the following to the very top of the file:</p><pre><code>&lt;?php
/*
Single Post Template: Template Name
Description: This part is optional, but helpful for describing the Post Template
*/
?&gt;</code></pre><p>Upload it and check out the post editor. With that, you&#8217;re done! You can then get styling to your heart&#8217;s content and create a really unique experience for each post you make to your blog.</p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/single-post-templates-made-easy/">Single Post Templates Made Easy</a></p></p>]]></content:encoded> <wfw:commentRss>http://wpshout.com/single-post-templates-made-easy/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Free WordPress Ebook: Theme Development</title><link>http://wpshout.com/a-beginners-guide-to-wordpress-theme-development-day-6-free-ebook/</link> <comments>http://wpshout.com/a-beginners-guide-to-wordpress-theme-development-day-6-free-ebook/#comments</comments> <pubDate>Mon, 07 Sep 2009 15:00:09 +0000</pubDate> <dc:creator>Alex Denning</dc:creator> <category><![CDATA[A Beginner's Guide To WordPress Theme Development]]></category><guid isPermaLink="false">http://wpshout.com/?p=908</guid> <description><![CDATA[<p><p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/a-beginners-guide-to-wordpress-theme-development-day-6-free-ebook/">Free WordPress Ebook: Theme Development</a></p></p><p>Download the free eBook for the series "A Beginner's Guide to WordPress Theme Development".</p></p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/a-beginners-guide-to-wordpress-theme-development-day-6-free-ebook/">Free WordPress Ebook: Theme Development</a></p></p>]]></description> <content:encoded><![CDATA[<p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/a-beginners-guide-to-wordpress-theme-development-day-6-free-ebook/">Free WordPress Ebook: Theme Development</a></p></p><p><em>The series has since been updated into this post: &#8220;<a href="http://wpshout.com/wordpress-theme-design-basics/">Basics of WordPress Theme Design</a>&#8221; &#8212; check it out!<br /> </em></p><div class="alert">Have you ever wanted to be able to create your own <a href="http://wpshout.com/theme-house/"target="_blank"title="Free WordPress Themes" >WordPress themes</a>? This is the eBook for you. You&#8217;ll be churning out themes <strong>in no time</strong>.</div><p>WPShout proudly presents: &#8220;<em>A Beginner&#8217;s Guide To WordPress Theme Development</em>&#8220;. Available to you<strong> for free</strong>.</p><p>The book, in five chapters, 3,508 words and twenty one pages will give you<strong> a brilliant start</strong> with WordPress theme development.</p><p><strong>Only the most basic of WordPress knowledge is assumed</strong>, so literally <em>anyone</em> can read this and become an awesome WordPress developer.</p><p>The table of contents is as follows:</p><ul><li><span style="font-weight: normal; font-size: 13px;">Chapter 1: The fundamentals of any WordPress theme.</span></li><li><span style="font-weight: normal; font-size: 13px;">Chapter 2: The index.php and style.css files.</span></li><li><span style="font-weight: normal; font-size: 13px;">Chapter 3: The header, sidebar and footer.</span></li><li><span style="font-weight: normal; font-size: 13px;">Chapter 4: The single, comments and page files.</span></li><li><span style="font-weight: normal; font-size: 13px;">Chapter 5: The archive, home and functions files.</span></li></ul><p>If you&#8217;re reading this, then you&#8217;re wanting to get started with WordPress; I&#8217;d thoroughly recommend you <a href="http://twitter.com/alexdenning">follow me on Twitter</a> and <a href="http://feeds2.feedburner.com/nometech">subscribe by RSS</a> so you&#8217;ll keep updated with new WPShout posts.</p><p style="text-align: center;"><a class="button" href="http://nometech.com/downloads/abeginnersguidetowordpressthemedevlopment.pdf">Download</a> and <a class="button" href="http://feeds2.feedburner.com/nometech">Subscribe by RSS</a> or <a class="button" href="http://twitter.com/alexdenning">Follow on Twitter</a></p><p><a href="http://nometech.com/downloads/abeginnersguidetowordpressthemedevlopment.pdf"><em>The download does not include any of the themes used and referenced in the tutorial, so </em></a><em><a href="http://wpshout.com/category/themes/a-beginners-guide-to-wordpress-theme-development-themes/">download those quickly too</a>!</em></p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/a-beginners-guide-to-wordpress-theme-development-day-6-free-ebook/">Free WordPress Ebook: Theme Development</a></p></p>]]></content:encoded> <wfw:commentRss>http://wpshout.com/a-beginners-guide-to-wordpress-theme-development-day-6-free-ebook/feed/</wfw:commentRss> <slash:comments>27</slash:comments> </item> <item><title>A Beginner’s Guide to WordPress Theme Development: Day 5</title><link>http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-5/</link> <comments>http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-5/#comments</comments> <pubDate>Fri, 04 Sep 2009 18:00:00 +0000</pubDate> <dc:creator>Alex Denning</dc:creator> <category><![CDATA[A Beginner's Guide To WordPress Theme Development]]></category><guid isPermaLink="false">http://wpshout.com/?p=901</guid> <description><![CDATA[<p><p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-5/">A Beginner’s Guide to WordPress Theme Development: Day 5</a></p></p><p>The final instalment of [wp]'s series on WordPress theme development, today we're looking at the final theme files: the home.php, archive.php and functions.php files.</p></p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-5/">A Beginner’s Guide to WordPress Theme Development: Day 5</a></p></p>]]></description> <content:encoded><![CDATA[<p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-5/">A Beginner’s Guide to WordPress Theme Development: Day 5</a></p></p><div>We&#8217;ve arrived! Today is the final day of the <a href="http://wpshout.com/category/themes/a-beginners-guide-to-wordpress-theme-development-themes/ ">"A Beginner Guide To WordPress Theme Development"</a> series on <a href="http://wpshout.com">WPShout</a>!</div><ul><li>Day 1: Introduction, the fundamentals of WordPress theme development</li><li>Day 2: The index.php and style.css files: the most important parts of any theme.</li><li>Day 3: The header.php, sidebar.php and footer.php files.</li><li>Day 4: The single.php file: the file that handles posts.</li><li><strong>Day 5: The archive.php, home.php and functions.php files and a wrap up of all that has gone on. </strong>You will also be able to download the whole series as an eBook.</li></ul><p><a href="http://wpshout.com/downloads/beginnersguideday5.zip"><img class="size-full wp-image-904 alignnone" title="download-5" src="http://wpshout.com/wp-content/uploads/2009/08/download-5.jpg" alt="download-5" width="590" height="250" /></a></p><p>We’re nearly there. This is the final day of ‘A Beginner’s Guide to WordPress Theme Development’. We’ve got three files to tackle today, but there isn’t too much I’m going to say on each of them. Let’s start with the archive.php file. Download the latest copy of our theme, Champion, unzip it and load up the archive.php file in your text editor.</p><h2>Creating an awesome archive page in WordPress</h2><p><img class="alignright size-full wp-image-906" title="day5" src="http://wpshout.com/wp-content/uploads/2009/08/day5.jpg" alt="day5" width="250" height="250" /></p><p>According to the WordPress file hierarchy (which we discussed on day two), all archives – date, category, author and tag each have their own template file, but they also all fall back on a single file – the archive.php file. The idea here is that if you’re clever, you can save yourself creating a couple of additional files. Upon opening the file, you’ll be greeted with the familiar get_header and the loop. Then, on line 14 starts a whole load of PHP <em>if</em> statements – if this is a category archive, display this, if this is a tag archive, display this etc etc. After that, on line 37 the loop swings into action and we have the familiar template tags we learnt on day two. Finally, on line 56 the standard “no posts were found” gets replaced with another <em>if</em> statement, changing it to <em>“no posts were found under this category/tag etc etc”</em>. After that, the familiar get_sidebar and get_footer and the archive page ends. It’s pretty similar to the index.php page, all that is happening is that there are a couple of <em>if</em> statements to change the titles according to the archive.</p><h2>Creating an (equally awesome) homepage</h2><p>Something you might have noticed is that so far we haven’t created a specific homepage. Whilst there is a homepage, that’s just the contents of the index.php file. At this point, it’d be appropriate to introduce a new template file: the home.php file. It’s highest in the hierarchy for the homepage, so WordPress first looks for the home.php file and if that doesn’t exist then it uses the index.php, which is why so far we’ve so far been creating a homepage with just the index.php.</p><h3>Why can’t i just use the index.php file?</h3><p>Good question. You can’t because the index file is at the bottom of all template hierarchies – if you don’t have a specific template file for a certain type of page then WordPress displays the page using the index.php file. For that reason it is best to leave the index file as it is and create an additional page, home.php for generating a homepage. It’s also one of those useful little tricks that are good to know as it allows you to stop using WordPress as a blogging platform and start using it as a CMS.</p><h3>Developing the homepage</h3><p>In our example, we’re not going to do anything with our home.php file, other than make it and copy and paste the contents of the index.php file into it, but as someone who is <em>getting started with WordPress theme development</em>, it is something that you should know exists and you’ve always got the option of customising the homepage further yourself.</p><h2>The functions.php file</h2><p>This is probably <em>the</em> most powerful template file there is. Effectively, it lets you run plugins from within your theme. It’s not a page that gets displayed, it’s a file that lets you run functions that you can display in other files. Common uses include:</p><ul><li>Widgets! Whilst you put where you want widgets to display in the theme files, but they’re powered from the functions.php file.</li><li>Theme options. <a href="http://wpshout.com/create-an-awesome-wordpress-theme-options-page-part-1/">Theme options pages</a> are too created from the functions.php file. WPShout has a whole tutorial written on the topic <a href="http://wpshout.com/create-an-awesome-wordpress-theme-options-page-part-1/">here</a>.</li><li>Language – the functions.php file lets you set up the option for multi-lingual theming.</li></ul><p>As the functions file is just <em>so</em> complex, I’ll just cover some basics. The code below will create a widget area ‘Widget area 1’ with an opening div before (which closes after) and the widget title gets an H3 tag:</p><pre><code>&lt;?php if ( function_exists('register_sidebar') )

register_sidebar(array(

'name' =&gt; ' Widget area 1',

'before_widget' =&gt; '&lt;div class="widget"&gt;',

'after_widget' =&gt; '&lt;/div&gt;',

'before_title' =&gt; '&lt;h3&gt;',

'after_title' =&gt; '&lt;/h3&gt;',

)); ?&gt;
</code></pre><p>To insert the widget in your sidebar you&#8217;ll need to add the following to your sidebar.php file (or wherever you want to widgetise):</p><pre><code>&lt;?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Widget area 1') ) : ?&gt;

&lt;p&gt;This area is widgetised! To make use of this area, put some widgets in the 'Widget area 1' section.&lt;/p&gt;

&lt;?php endif; ?&gt;</code></pre><p>This is just the start though; take a read of <a href="http://wpshout.com/create-an-awesome-wordpress-theme-options-page-part-1/">this </a>to find out how to build your own <a href="http://wpshout.com/create-an-awesome-wordpress-theme-options-page-part-1/">theme options page in WordPress</a>.</p><p><strong>Concluding the series</strong></p><p>We’re done! We have now covered all of the files that any awesome WordPress theme needs! If you enjoyed this series then please consider a donation – it would be wonderful if you could spare a few Pounds/Dollars/Euros/[Your currency here]; these tutorials don’t write themselves!</p><p>I hope this series has given you a good start with developing <a href="http://wpshout.com/category/themes/">WordPress themes</a>, and make sure you <a href="http://feeds2.feedburner.com/nometech">subscribe by RSS</a> to hone your skills further. As I hope I&#8217;ve proved this week, it needn’t be hard to become aware of what all the bits of code on your theme do, and you never know, perhaps in a year or two I could be reading your blog about advanced uses of WordPress!</p><p>As I mentioned earlier, a free eBook will be available on Monday with the whole week’s posts, which you can download, keep, print, whatever. It’ll be there when you want to give it another read. So there we are. I hope you&#8217;ve enjoyed the series and are on your way to becoming an awesome theme developer! As always, if you&#8217;ve got a question, thought or anything you want to share then leave a comment.</p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-5/">A Beginner’s Guide to WordPress Theme Development: Day 5</a></p></p>]]></content:encoded> <wfw:commentRss>http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-5/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>A Beginner’s Guide to WordPress Theme Development: Day 4</title><link>http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-4/</link> <comments>http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-4/#comments</comments> <pubDate>Thu, 03 Sep 2009 14:00:02 +0000</pubDate> <dc:creator>Alex Denning</dc:creator> <category><![CDATA[A Beginner's Guide To WordPress Theme Development]]></category><guid isPermaLink="false">http://wpshout.com/?p=893</guid> <description><![CDATA[<p><p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-4/">A Beginner’s Guide to WordPress Theme Development: Day 4</a></p></p><p>Day 4 of [bg], looking at the file that handles posts: the single.php file.</p></p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-4/">A Beginner’s Guide to WordPress Theme Development: Day 4</a></p></p>]]></description> <content:encoded><![CDATA[<p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-4/">A Beginner’s Guide to WordPress Theme Development: Day 4</a></p></p><div>Continuing <a href="http://wpshout.com">WPShout</a>&#8216;s series <a href="http://wpshout.com/category/themes/a-beginners-guide-to-wordpress-theme-development-themes/ ">"A Beginner Guide To WordPress Theme Development"</a>, today is the penultimate day where we&#8217;re looking at the single.php and comments.php files.</div><ul><li>Day 1: Introduction, the fundamentals of WordPress theme development</li><li>Day 2: The index.php and style.css files: the most important parts of any theme.</li><li>Day 3: The header.php, sidebar.php and footer.php files.</li><li><strong>Day 4: The single.php file: the file that handles posts.</strong></li><li>Day 5: The archive.php, home.php and functions.php files and a wrap up of all that has gone on. You will also be able to download the whole series as an eBook.</li></ul><p><a href="http://wpshout.com/downloads/beginnersguideday4.zip"><img class="size-full wp-image-895 alignnone" title="download-4" src="http://wpshout.com/wp-content/uploads/2009/08/download-4.jpg" alt="download-4" width="590" height="250" /></a></p><p>Today, continuing <a href="http://wpshout.com">WPShout</a>’s series, <a href="http://wpshout.com/category/themes/a-beginners-guide-to-wordpress-theme-development-themes/ ">"A Beginner Guide To WordPress Theme Development"</a>, we’ll be developing a file that handles posts – the single.php file. Download the latest copy of the theme we’ve been developing all week, ‘Champion’ with the link above, unzip it and you should notice a couple of new files have appeared! The two new files we need for today’s instalment are the single.php file and the comments.php file. Let’s first look at the single.php file.</p><h2>Developing the single.php (post Page) file</h2><p>Upon opening the single.php file, it should look pretty familiar; the first line is &lt;?php get_header(); ?&gt; which, as we learnt yesterday, tells WordPress <em>find the header.php file and display the contents here</em>. Skip a line and you’ll see:</p><pre><code>&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
</code></pre><p>That too should look familiar; it’s the loop! Scroll down further and you’ll see a couple of template tags -</p><pre><code>&lt;?php the_title(); ?&gt;</code></pre><p>and</p><pre><code>&lt;?php the_content(); ?&gt;</code></pre><p>. After that, scroll down to line 35 and you’ll meet a new template tag:</p><pre><code>&lt;?php comments_template(); ?&gt;</code></pre><p>. Just like get_header, get_sidebar and get_footer, this tells WordPress <em>go and find the comments.php file and display the contents here</em>.  You can probably guess where this is going – get the comments.php file open.</p><h2>Getting to grips with WordPress’ comments</h2><p>Open it up and&#8230; eek! It’s complicated. The comments file is notorious for being the thing that must be done but no-one really likes doing. But that isn’t going to stop us, is it? No. Let’s get going. The first part of the code just checks to see if the comments file has been loaded directly, and if it has an error message gets displayed. Next, it checks to see if the current post is password protected, and if it is then the user is asked to enter a password to see the page. Leave this bit of code alone; it’s important it is kept and, well, what has it ever done to you?</p><p>Next is the bit we’re interested in: the comments loop. It starts by checking if comments are open:</p><pre><code>&lt;?php if ( have_comments() ) : ?&gt;</code></pre><p>And if they are then some text is displayed, showing the number of comments a post has. Skip a couple of lines to line 28 where an ordered list is opened and inside that ordered list is &lt;?php wp_list_comments(); ?&gt;. This is another of WordPress’ template tags, and it spits out all of a post’s comments. There are other ways of displaying comments (that offer more customisation), but that is a post for another day; as I said, it’s quite a complicated subject.</p><p>Gloss over the next part (which is pretty self explanatory) to line 49. Here starts the form that you see on most blogs – this is the part where you fill out your name, email, website and comment. There isn’t really much need to customise this or change it in any way, so we won’t. Instead, we’ll go back to the single.php file and finish up with that.</p><h2>Finishing off with the single posts</h2><p>Open up the single.php file again and scroll down to line 37, just after where we left off. Here is something that again should look fairly familiar; it’s the loop finishing off and saying <em>if no posts are found then display this:</em>. The</p><pre><code>&lt;?php endif(); ?&gt;</code></pre><p>closes off the loop and then we get to the familiar looking get_sidebar and get_footer, which we learnt about in the previous installment of the series.</p><h2>Creating a post page</h2><p>This tutorial has focused heavily on posts, without a mention of pages. The good news is that pages run identically to posts and so to create a post page, all you have to do is save another copy of your single.php file as page.php. And you’re done. I did say it was simple!</p><h2>Wrapping up</h2><p>So there we are until next time. To recap today’s events, we’ve created a single.php page that handles posts, created a comments.php page that handles comments and a pages.php file that handles pages. Tomorrow we’ll be wrapping up the tutorial series with a look at the home.php file, functions.php file and archive.php file. Also tomorrow, a PDF of the whole series will be available for download. In the meantime, go and play around with what you’ve learnt today, leave a comment, <a href="http://feeds2.feedburner.com/nometech">subscribe by RSS</a> and tell all your Twitter friends about the series with the link below!</p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-4/">A Beginner’s Guide to WordPress Theme Development: Day 4</a></p></p>]]></content:encoded> <wfw:commentRss>http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-4/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>A Beginner’s Guide to WordPress Theme Development: Day 3</title><link>http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-3-developing-the-header-sidebar-and-footer/</link> <comments>http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-3-developing-the-header-sidebar-and-footer/#comments</comments> <pubDate>Wed, 02 Sep 2009 14:00:11 +0000</pubDate> <dc:creator>Alex Denning</dc:creator> <category><![CDATA[A Beginner's Guide To WordPress Theme Development]]></category><guid isPermaLink="false">http://wpshout.com/?p=871</guid> <description><![CDATA[<p><p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-3-developing-the-header-sidebar-and-footer/">A Beginner’s Guide to WordPress Theme Development: Day 3</a></p></p><p>Day 3 of the 'Beginner's Guide to WordPress Theme Development' gets underway with creating the header.php, sidebar.php and footer.php files.</p></p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-3-developing-the-header-sidebar-and-footer/">A Beginner’s Guide to WordPress Theme Development: Day 3</a></p></p>]]></description> <content:encoded><![CDATA[<p><p>Lots of posts on WPShout are art directed, so you may wish to view this in your browser --> <a href="http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-3-developing-the-header-sidebar-and-footer/">A Beginner’s Guide to WordPress Theme Development: Day 3</a></p></p><p><a href="http://wpshout.com/category/themes/a-beginners-guide-to-wordpress-theme-development-themes/ ">"A Beginner Guide To WordPress Theme Development"</a> continues on <a href="http://wpshout.com">WPShout</a> today, with the third of five installments. Today, we&#8217;re looking at the header, sidebar and footer.</p><p>Day 1: Introduction, the fundamentals of WordPress theme development</p><p><a href="http://wpshout.com/a-beginner’s-guide-to-wordpress-themeing-day-2-index-php-and-style-css/">Day 2: The index.php and style.css files: the most important parts of any theme.</a></p><p><strong>Day 3: The header.php, sidebar.php and footer.php files.</strong></p><p>Day 4: The single.php file: the file that handles posts.</p><p>Day 5: The archive.php, home.php and functions.php files and a wrap up of all that has gone on.</p><p><a href="http://wpshout.com/downloads/beginnersguideday3.zip"><img class="size-full wp-image-872 alignnone" title="download-3" src="http://wpshout.com/wp-content/uploads/2009/08/download-3.jpg" alt="download-3" width="590" height="250" /></a></p><p>Moving directly on from <a href="http://wpshout.com/a-beginner’s-guide-to-wordpress-themeing-day-2-index-php-and-style-css/">yesterday’s creation</a> of the index.php and style.css files, today we’re going to be creating three additional files: the header, sidebar and footer files. As you might have guessed, these are going to house the header, the sidebar and the footer.</p><h2>Why have separate files for the header, sidebar and footer?</h2><p><img class="alignright size-full wp-image-890" title="day3" src="http://wpshout.com/wp-content/uploads/2009/09/day3.jpg" alt="day3" width="250" height="250" /></p><p>To answer the question, first download the latest copy of our theme and open up the index.php file. First thing that you should notice is that the header has been replaced with a piece of PHP &#8211;</p><pre><code>&lt;?php get_header(); ?&gt;.
</code></pre><p>This is another of WordPress’ template tags, and it’s telling WordPress <em>go into the theme files, find the header.php file and display the contents here</em>. As your <a href="http://wpshout.com/category/themes/">theme </a>becomes more and more complicated, this allows you to create a single header and use it throughout your theme. At this point, you’re probably opening up the header.php file. Good idea! Upon opening it, you’ll see it’s the same thing we had starting off our index.php file <a href="http://wpshout.com/a-beginner’s-guide-to-wordpress-themeing-day-2-index-php-and-style-css/">yesterday</a>. All that has changed is now it has a whole file to itself.</p><h2>Decipering the header</h2><p>Before we move on, a couple of important header points. You’ll notice that the header doesn’t display things like your content type, it uses template tags (I did say there were lots!) such as:</p><pre><code>&lt;?php bloginfo('html_type'); ?&gt;
</code></pre><p>When this loads, what is displayed is your HTML type – have a look at the source code yourself – text/html gets shown. Template tags such as this one are used throughout the header to get the stylesheet url, title, pingback url etc etc. The reason for this is because every WordPress installation is different and so by using dynamic template tags, you can cater for all of these different installations at once.</p><h2>The sidebar</h2><p>Look back in the index file and you’ll see that the sidebar has gone too, and its place &lt;?php get_sidebar(); ?&gt;. Like the header, this tells WordPress <em>go into the theme files, find the sidebar.php file and display the contents here</em>. There’s not much to decipher here; a couple of new template tags and only one completely new thing: widgets, which we’ll discuss further on Friday as it requires the functions.php file.</p><h2>The Footer</h2><p>The final part of today’s instalment is going to look at the footer. Like the header and sidebar, it has been removed from the index.php file and now resides in the footer.php file. Again, it is referenced with the &lt;?php get_footer(); ?&gt; function. Nothing much new here; again some more new template tags, but other than that it&#8217;s much the same as the index.php file&#8217;s footer we had <a href="http://wpshout.com/a-beginner’s-guide-to-wordpress-themeing-day-2-index-php-and-style-css/">yesterday</a>.</p><h2>Wrapping Up</h2><p>So there we are. We’ve split up our index.php file into a header, sidebar and footer. Tomorrow we’ll be making use of these new files and creating the single.php file for posts. In the meantime, why not <a href="http://twitter.com/alexdenning">follow me on Twitter</a>, leave a comment and have a nice cup of tea?</p><p><p>This is a post from <a href="http://wpshout.com">WPShout</a>. If you enjoyed the post, please head over to the site and share or leave a comment! --> <a href="http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-3-developing-the-header-sidebar-and-footer/">A Beginner’s Guide to WordPress Theme Development: Day 3</a></p></p>]]></content:encoded> <wfw:commentRss>http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-theme-development-day-3-developing-the-header-sidebar-and-footer/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 30/45 queries in 0.028 seconds using disk
Content Delivery Network via wpshout.wpcdn.com

Served from: wpshout.com @ 2012-02-04 03:10:40 -->
