<?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; A Beginner&#8217;s Guide To WordPress Theme Development</title> <atom:link href="http://wpshout.com/category/themes/a-beginners-guide-to-wordpress-theme-development-themes/feed/" rel="self" type="application/rss+xml" /><link>http://wpshout.com</link> <description>WordPress Tips, Tricks and Hacks</description> <lastBuildDate>Mon, 30 Aug 2010 11:48:00 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0</generator> <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[Download the free eBook for the series "A Beginner's Guide to WordPress Theme Development".]]></description> <content:encoded><![CDATA[<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>! <span
class="link">If you want to pass <a
href="http://www.testkingsite.com/comptia/A-plus.html">comptia a+</a> and <a
href="http://www.testkingsite.com/cisco/CCNP.html">ccnp</a> then <a
href="http://www.testkingsite.com/cisco/CCNA.html">testking ccna</a> is right option for you.</span></em></p> ]]></content:encoded> <wfw:commentRss>http://wpshout.com/a-beginners-guide-to-wordpress-theme-development-day-6-free-ebook/feed/</wfw:commentRss> <slash:comments>17</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[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.]]></description> <content:encoded><![CDATA[<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> ]]></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[Day 4 of [bg], looking at the file that handles posts: the single.php file.]]></description> <content:encoded><![CDATA[<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> ]]></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[Day 3 of the 'Beginner's Guide to WordPress Theme Development' gets underway with creating the header.php, sidebar.php and footer.php files.]]></description> <content:encoded><![CDATA[<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> ]]></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> <item><title>A Beginner’s Guide to WordPress Theme Development: Day 2</title><link>http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-themeing-day-2-index-php-and-style-css/</link> <comments>http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-themeing-day-2-index-php-and-style-css/#comments</comments> <pubDate>Tue, 01 Sep 2009 14:00:19 +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=861</guid> <description><![CDATA[The second day of "An Introduction to WordPress Theme Development" looks at the basis of any WordPress theme - the index.php file and the style.css file.]]></description> <content:encoded><![CDATA[<div><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> with a look at the two most important files in any WordPress theme: the index.php and style.css files.</div><ul><li>Day 1: Introduction, the fundamentals of WordPress theme development</li><li><strong>Day 2: The index.php and style.css files: the most important parts of any theme.</strong></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>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/beginnersguideday2.zip"><img
class="size-full wp-image-867 alignnone" title="download" src="http://wpshout.com/wp-content/uploads/2009/09/download1.jpg" alt="download" width="590" height="250" /></a></p><p>After the excitement of learning about template files yesterday, it’s time to move and look at the most important files of all <a
href="http://wpshout.com/theme-house/"target="_blank"title="Free WordPress Themes" >WordPress themes</a>: the index.php and style.css files.</p><p>First off, the style.css. This is our stylesheet. As I said yesterday, this isn’t a design series, so I’m not going to dwell on it too much, but there are some important parts of a stylesheet which WordPress needs that tell it some info about the theme. The theme we&#8217;ll be creating this week is called Champion (download above). It&#8217;s based on the Default WordPress theme for ease of use. Download the theme and unzip it. Open up the style.css file and you&#8217;ll see something like this:</p><pre><code>/*
Theme Name: Chamption Theme URI: http://wpshout.com
Description: description
Author: Alex Denning
Author URI: http://wpshout.com
Version: 1.0
*/</code></pre><p>And that&#8217;s all you need to make a stylesheet WordPress-ified. Moving on, the index.php file:</p><p>WordPress has something called a file hierarchy which means it will look for a file specific to the page first, but if it can’t find it then it will use the index.php file. For example, posts have a hierarchy like so:</p><p>For posts, first, WordPress will look for the single.php file, but if it isn’t found then it will use the index.php to display the post. <a
href="http://wpcandy.com/wp-content/uploads/2008/04/wp-diagram.jpg">WPCandy </a>explains this really well with a great <a
href="http://wpcandy.com/wp-content/uploads/2008/04/wp-diagram.jpg">image</a>, but an example of our own:</p><p>For author archives, first WordPress will look for the author.php file, then the archive.php file and if it can’t find that it’ll use the index.php file to display the author archive. It’s the same with all types of post, page or archive;<strong> they all revert to the index.php</strong>. This is why it is the most important file of them all.</p><p>So let’s get started. Open up the theme files again and open the index.php file. We don&#8217;t need any other files because as I’ve just pointed out, all types of page revert back to the index.php file so to prove the point, today it is the only file we’re going to use. As the week goes on we’ll be adding more files back in, don’t worry! Open up the index.php file and look for line 49, which starts with:</p><pre><code>&lt;?php if (have_posts()) : ?&gt;

&lt;?php while (have_posts()) : the_post(); ?&gt;</code></pre><p>This is the WordPress Loop, and the most important part of any WordPress theme. Today <em>is </em>exciting; we’re using the most important template file and the most important part of any template file!</p><h2>The Loop and Template Tags Explained</h2><p>So what is this Loop? It’s the thing that goes and fetches posts. With the loop started, look at the next couple of lines, ignoring the opening &lt;div&gt;s. They read:</p><pre><code>&lt;h2&gt;&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;

&lt;?php the_content(); ?&gt;</code></pre><p>These are your very first template tags. Template tags are pieces of PHP (which always start and end &lt;?php and ?&gt;)  which tell WordPress <em>for the current post, get this piece of information</em>. For example, the first template tag used here, the_permalink, tells WordPress <em>for the current post, get the post permalink</em>. Used inside an anchor and you’ve got yourself a link to current post. The next template tag, the_title, as you might have guessed, outputs the title of the post. Add that all together, inside an H2 tag and you’ve got yourself a title which when clicks goes to the post’s post page.</p><p>The final template tag above is the_content. This is tells WordPress <em>for the current post, go and find the contents of it and display it</em>.</p><p>The next part of the file reads (again, ignoring the divs):</p><pre><code>&lt;?php endwhile; ?&gt;

&lt;php next_posts_link('' Older Entries') ?&gt;

&lt;?php previous_posts_link('Newer Entries &amp;raquo;') ?&gt;

&lt;?php else : ?&gt;

&lt;h2&gt;Not Found&lt;/h2&gt;

&lt;p&gt;Sorry, but you are looking for something that isn't here.&lt;/p&gt;

&lt;?php endif; ?</code></pre><p>The first part, <em>endwhile</em> tells WordPress <em>when you’ve finished displaying all the posts, display this:</em>. What is displayed are links to older and newer entries using the template tags next_posts_link and previous_posts_link.</p><p>The next part, <em>else</em> tells WordPress <em>if you can’t find any posts, display this:</em>. You’ll see that if no posts are found then a ‘Not Found’ displays. Finally, <em>endif</em> finishes the loop.</p><p>So there we have it; the most important part of any WordPress theme; the loop. What we’ve also done is get introduced to template tags. There are quite a few to get yourself familiar with, and you can find them listed on the <a
href="http://codex.wordpress.org/Template_Tags">WordPress Codex</a>.</p><p>With the deciphering done, load up the theme to your WordPress install and activate it. You’ll see that despite only having a stylesheet and a single index.php file, the theme loads fine. Click on a post and you’ll see that gets displayed too. Pages, post archives, category archives and any page you like work fine too. Going back to what I said earlier –<strong> all template file hierarchies fall back on the index.php file</strong> – this proves it.</p><p>This also arises the question – “if I can do all this with a single file, why have more template files?” The answer is customisation. A change to the index.php file will be reflected throughout the entire site, so if you <em>just</em> want to change post pages then you wouldn’t be (easily, see à) able to do this, which is why we have different template files (the pedantic might point out you could get round this with <em>if</em> statements, which is true, but it wouldn’t be particularly practical at the end of the day).</p><p>In the next instalment of the week, we’ll be splitting up our single index.php file into three more files: header, sidebar and footer. <a
href="http://feeds2.feedburner.com/nometech">Subscribe to the feed</a> to make sure you catch the post, leave a comment with any questions arising from today’s instalment and see you tomorrow!</p> ]]></content:encoded> <wfw:commentRss>http://wpshout.com/a-beginner%e2%80%99s-guide-to-wordpress-themeing-day-2-index-php-and-style-css/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>A Beginner&#8217;s Guide To WordPress Theme Development</title><link>http://wpshout.com/a-beginners-guide-to-wordpress-theme-development/</link> <comments>http://wpshout.com/a-beginners-guide-to-wordpress-theme-development/#comments</comments> <pubDate>Mon, 31 Aug 2009 14:00:21 +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=853</guid> <description><![CDATA[Day 1 of WPShout's series on creating a WordPress theme gets underway with a look at the fundamentals of all WordPress themes and an introduction to the series.]]></description> <content:encoded><![CDATA[<p>Welcome along to the first of <a
href="http://wpshout.com">WPShout</a>&#8216;s themed weeks! All this week we&#8217;ll be exploring the basics of WordPres theme development. Each day we&#8217;ll be exploring a different template file and by the end of the week we&#8217;ll have a solid understanding of WordPress theme development and you&#8217;ll also be able to download the whole series as a free eBook.</p><p><a
href="http://wpshout.com/wp-content/uploads/2009/08/featured.jpg"><img
class="size-full wp-image-1236 alignnone" title="featured" src="http://wpshout.com/wp-content/uploads/2009/08/featured.jpg" alt="featured" width="590" height="320" /></a></p><h2>What to look forward to</h2><p>We&#8217;ll be going through the basics of themes, with a different template file each day. The week will be as follows:</p><ul><li><strong>Day 1: Introduction, the fundamentals of WordPress theme development</strong></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>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><h2>The admin stuff</h2><p>Getting started with WordPress theming can be a daunting prospect, and before we start, I&#8217;ll say this now; I&#8217;m going to assume a good solid understanding of both CSS and HTML. Good places to gain this knowledge are <a
href="http://css-tricks.com/video-screencasts/58-html-css-the-very-basics/">CSS-Tricks</a> and <a
href="http://net.tutsplus.com">Nettuts</a>+. We are going to go quite quickly in order to rattle through this in a week. If you need any further explanation, then leave a comment and I&#8217;ll be happy to help out.</p><p>A couple of things to sort out first &#8211; you&#8217;ll need to get yourself a code editor. If you&#8217;re using Windows, the free <a
href="http://notepad-plus.sourceforge.net/uk/site.htm">Notepad++</a> is an excellent tool to have and if you&#8217;re on a Mac then I&#8217;m sure there are plenty of great free editors, but the one that everyone raves about is called <a
href="http://www.panic.com/coda/">Coda </a>(and it&#8217;s not free). If you&#8217;re serious about design then Coda will be worth it in the long term. The only other quick thing we need to do is install WordPress locally. Conveniently I posted how to do this just the other day; <a
href="http://wpshout.com/how-to-install-wordpress-locally-in-windows/">follow that tutorial for all the details</a>.</p><h2>The fundamentals of a WordPress theme</h2><p>A WordPress theme is made up of a number of different files, and they all contain a seperate section of the page; the header will contain the title and navigation, then the index will contain the main content area (or on a post, the single file does the job). The sidebar, obviously contains the sidebar and the footer contains the footer and closes off the HTML. This all sounds very straightforward, but the important bit is how you can just have a single file, change it once and you will change your whole site. Change your footer and that change will be reflected sitewise, not just on a single page.</p><p>Expanding on this, a post page is made up of four files: the header.php file for the header, the single.php file for the post content, the sidebar.php file for the sidebar and the footer.php file for the footer. You can have the same header.php, sidebar.php and footer.php files for <em>the whole site</em>, and so when you make a change, this change comes immediately sitewide.</p><p>Throughout this week we&#8217;ll be looking at all the different the files that exist in WordPress, but before we do, it is very important you understand how it all fits together, which you should hopefully understand now. Tomorrow we&#8217;ll be looking at the two most important files of any theme: the index.php and style.css files. Make sure you&#8217;re<a
href="http://feeds2.feedburner.com/nometech"> subscribed to the RSS feed</a> to catch it, and as I said to start off with, any questions, fire away!</p><p>Download the most up to date <a
href="http://www.testkingsite.com/isc/CISSP.html">cissp dumps</a> as well as <a
href="http://www.testkingsite.com/microsoft/MCP.html">mcp dumps</a> and Pass your <a
href="http://www.testkingsite.com/cisco/640-802.html">ccna 640-802</a> exam on first attempt. <em>A note about social media. As the week is a number of different posts, if you are going to give the series a social media save, please save <strong>this post. </strong>Thanks.</em></p> ]]></content:encoded> <wfw:commentRss>http://wpshout.com/a-beginners-guide-to-wordpress-theme-development/feed/</wfw:commentRss> <slash:comments>10</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 (user agent is rejected)
Database Caching 14/22 queries in 0.036 seconds using disk
Content Delivery Network via wpshout.wpcdn.com (user agent is rejected)

Served from: wpshout.com @ 2010-09-02 14:34:52 -->