<?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>Digging into WordPress &#187; Theme</title>
	<atom:link href="http://digwp.com/category/theme/feed/" rel="self" type="application/rss+xml" />
	<link>http://digwp.com</link>
	<description>Learn how to take your WordPress skills to the next level.</description>
	<lastBuildDate>Thu, 18 Mar 2010 12:24:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Custom Comments HTML&#160;Output</title>
		<link>http://digwp.com/2010/02/custom-comments-html-output/</link>
		<comments>http://digwp.com/2010/02/custom-comments-html-output/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 20:04:01 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Theme]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1469</guid>
		<description><![CDATA[Displaying all the comments on a Post is incredibly easy. In your single.php file you probably have a line like this:
&#60;?php comments_template(); ?&#62;
That line basically calls/includes your comments.php file. Within that, the line to output all comments is something really simple like this:
&#60;ol class="commentlist"&#62;
   &#60;?php wp_list_comments(); ?&#62;
&#60;/ol&#62;
But that doesn&#8217;t leave much by way [...]]]></description>
			<content:encoded><![CDATA[<p>Displaying all the comments on a Post is incredibly easy. In your single.php file you probably have a line like this:</p>
<pre><code>&lt;?php comments_template(); ?&gt;</code></pre>
<p>That line basically calls/includes your comments.php file. Within that, the line to output all comments is something really simple like this:</p>
<pre><code>&lt;ol class="commentlist"&gt;
   &lt;?php wp_list_comments(); ?&gt;
&lt;/ol&gt;</code></pre>
<p>But that doesn&#8217;t leave much by way of customizing the HTML that gets output, does it? Fortunately it&#8217;s fairly easy to specify your own formatting in a non-destructive non-core-altering way. Although personally, I&#8217;m having one little issue with it. Let&#8217;s take a look.</p>
<p><span id="more-1469"></span></p>
<h3>Why would you need this?</h3>
<p>This is what you get as the defacto standard comment output:</p>
<div class="image-wrap">
<img src="http://digwp.com/wp-content/blog-images/comment-output.jpg" width="590" height="420" alt="" title="" /><br />
This is from the new 2010 theme slated to come out with WordPress 3
</div>
<p>But what if you wanted something more like this?</p>
<div class="image-wrap">
<img src="http://digwp.com/wp-content/blog-images/redonecomment.png" width="529" height="234" alt="" title="" /><br />
From a new client site I&#8217;ve been working on
</div>
<p>The best way to get into that new skin is to get your hands on the HTML, as CSS alone isn&#8217;t quite going to get us there.</p>
<h3>Custom output through a callback function</h3>
<p>The trick is is that the wp_list_comments function accepts a parameter for a callback function. This function overrides what the output of each comment will be. Here is an example of that:</p>
<pre><code>&lt;ol class="commentlist"&gt;
    &lt;?php wp_list_comments('type=comment&amp;callback=format_comment'); ?&gt;
&lt;/ol&gt;</code></pre>
<p>The above code will only output &#8220;comments&#8221; (and not trackbacks or pingbacks) and will call a custom function &#8220;format_comment&#8221; for formatting the comment. This function needs to be built in your functions.php file, and better be present before you call this function otherwise you&#8217;ll throw an error.</p>
<p>The callback function is completely in charge of the comment formatting. It could be something completely whacky like this:</p>
<pre><code>&lt;?php
    function format_comment() {  ?&gt;
           &lt;li&gt;This is whack, yo.&lt;/li&gt;
   &lt;?php } 
?&gt;</code></pre>
<p>Which would return that ridiculous sentence for every single comment, instead of the actual comment. Of course you wouldn&#8217;t (probably) ever do that. What you probably want to do, is just adjust how the different standard comment-related data is output. To do that, first you pull in the comment globals, then you can use all the comment functions that return the stuff that you probably want:</p>
<ul>
<li>get_comment_link</li>
<li>get_comment_author</li>
<li>get_comment_date</li>
<li>get_comment_time</li>
<li>get_comment_text</li>
<li>etc.</li>
</ul>
<p>Here is a customized formatting function I recently used:</p>
<pre><code>&lt;?php

    function format_comment($comment, $args, $depth) {
    
       $GLOBALS['comment'] = $comment; ?&gt;
       
        &lt;li &lt;?php comment_class(); ?&gt; id="li-comment-&lt;?php comment_ID() ?&gt;"&gt;
                
            &lt;div class="comment-intro"&gt;
                &lt;em&gt;commented on&lt;/em&gt; 
                &lt;a class="comment-permalink" href="&lt;?php echo htmlspecialchars ( get_comment_link( $comment-&gt;comment_ID ) ) ?&gt;"&gt;&lt;?php printf(__('%1$s'), get_comment_date(), get_comment_time()) ?&gt;&lt;/a&gt;
                &lt;em&gt;by&lt;/em&gt; 
                &lt;?php printf(__('%s'), get_comment_author_link()) ?&gt;
            &lt;/div&gt;
            
            &lt;?php if ($comment-&gt;comment_approved == '0') : ?&gt;
                &lt;em&gt;&lt;php _e('Your comment is awaiting moderation.') ?&gt;&lt;/em&gt;&lt;br /&gt;
            &lt;?php endif; ?&gt;
            
            &lt;?php comment_text(); ?&gt;
            
            &lt;div class="reply"&gt;
                &lt;?php comment_reply_link(array_merge( $args, array('depth' =&gt; $depth, 'max_depth' =&gt; $args['max_depth']))) ?&gt;
            &lt;/div&gt;
        
&lt;?php } ?&gt;</code></pre>
<h3>When NOT to customize output</h3>
<p>Remember that CSS is quite the handyman at whipping things into shape. Let&#8217;s say your goal was to get rid of the gravatars that the default comment formatting outputs. Well that&#8217;s as simple as:</p>
<pre><code>.avatar { display: none; }</code></pre>
<p>And with more powerful tools like absolute positioning, you can take the default output and really do a ton of customization. There are some times though, when you need to alter the HTML to do it right, and that&#8217;s when all this is useful.</p>
<h3>My little problem</h3>
<p>My custom output works really well, save for one little problem. That is nested replies. The WORK, it&#8217;s just the output is invalid, as nested lists sit directly within the list above it instead of being wrapped in a list item like they should be. See:</p>
<p><img src="http://digwp.com/wp-content/blog-images/naughtyoutput.jpg" width="590" height="720" alt="" title="" /></p>
<p>I&#8217;m not quite sure how to fix that, although I imagine it can be done within the custom function somehow? If anyone knows, let me know.</p>
<h3>Update</h3>
<p>It was my mistake, although in my defense, the answer is a little weird. What you need to is <strong>OMIT</strong> the closing <code>&amp;lt;/li&amp;gt;</code> tag in the callback function. WordPress will add that automatically for you. </p>
<p>In other news, if you find your callback function breaks the &#8220;Reply&#8221; button functionality, take a look at the <code>add_below</code> parameter:</p>
<pre><code>&lt;?php comment_reply_link(array_merge( $args, array('reply_text' =&gt; 'Reply', 'add_below' =&gt; $add_below, 'depth' =&gt; $depth, 'max_depth' =&gt; $args['max_depth']))); ?&gt; </code></pre>
<p>That parameter takes a string, like &#8220;div-comment&#8221; for example, and then the reply links on each comment will be looking for the page element of &#8220;div-comment-XXXX&#8221; to jump the comment form up to (where XXXX is the ID of the comment). So your theme better have page elements with matching ID&#8217;s, or the reply link will &#8220;fail&#8221; and reload the page. I say &#8220;fail&#8221; in quotes because replying will still work, it just doesn&#8217;t do the cool jump-up technique which is the whole point of the <code>comment-reply.js</code> file that most themes load on single pages.</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/02/custom-comments-html-output/">Permalink</a> | <a href="http://digwp.com/2010/02/custom-comments-html-output/#comments">12 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2010/02/custom-comments-html-output/&title=Custom Comments HTML&nbsp;Output">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/theme/" title="View all posts in Theme" rel="category tag">Theme</a> | Tagged: <a href="http://digwp.com/tag/comments/" rel="tag">comments</a>, <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/php/" rel="tag">PHP</a>, <a href="http://digwp.com/tag/theme/" rel="tag">Theme</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/02/custom-comments-html-output/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Which Template File does WordPress Use to Render Different&#160;Pages?</title>
		<link>http://digwp.com/2010/02/template-heirarchy-chart/</link>
		<comments>http://digwp.com/2010/02/template-heirarchy-chart/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 14:34:51 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Theme]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1431</guid>
		<description><![CDATA[This page in the codex has a particularly interesting infographic that shows a flowchart of how WordPress chooses which template file it is going to use to render the page. For example, did you know if you have a published page with &#8220;contact&#8221; as the slug, it will look for and use page-contact.php automatically?
Unfortunately this [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://codex.wordpress.org/Template_Hierarchy">This page</a> in the codex has a particularly interesting infographic that shows a flowchart of how WordPress chooses which template file it is going to use to render the page. For example, did you know if you have a published page with &#8220;contact&#8221; as the slug, it will look for and use page-contact.php automatically?</p>
<p>Unfortunately this graphic wasn&#8217;t very pretty and for some reason has a giant &#8220;Page 1&#8243; text awkward sitting over it. We have an outdated version of this in the book, and since we are updating it right now, I thought I would take the opportunity to re-create this chart.</p>
<p><span id="more-1431"></span></p>
<p><a href="http://digwp.com/wp-content/blog-images/whichtemplate-large.png">CLICK FOR FULL SIZE VERSION</a><br />
<a href="http://digwp.com/wp-content/blog-images/whichtemplate-large.png"><img src="http://digwp.com/wp-content/blog-images/whichtemplate-small.png" width="590" height="472" alt="" title="" /></a></p>
<p>This will also be used in the <a href="http://digwp.com/book/">book</a>, which should be back available for order in around a week or so! Stay tuned!</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/02/template-heirarchy-chart/">Permalink</a> | <a href="http://digwp.com/2010/02/template-heirarchy-chart/#comments">12 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2010/02/template-heirarchy-chart/&title=Which Template File does WordPress Use to Render Different&nbsp;Pages?">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/theme/" title="View all posts in Theme" rel="category tag">Theme</a> | Tagged: <a href="http://digwp.com/tag/template/" rel="tag">template</a>, <a href="http://digwp.com/tag/theme/" rel="tag">Theme</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/02/template-heirarchy-chart/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>BLANK WordPress&#160;Theme</title>
		<link>http://digwp.com/2010/02/blank-wordpress-theme/</link>
		<comments>http://digwp.com/2010/02/blank-wordpress-theme/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 15:43:26 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Theme]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[free]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=981</guid>
		<description><![CDATA[There are many like it, but this one is mine. 
I have a &#8220;blank&#8221; WordPress theme for myself, because I make a lot of WordPress themes. Starting from Kubrick, or any other pre-made theme, would be absurd. There is to much stuff there that would to be stripped out or fought against to be useful. [...]]]></description>
			<content:encoded><![CDATA[<p>There are many like it, but this one is mine. </p>
<p>I have a &#8220;blank&#8221; WordPress theme for myself, because I make a lot of WordPress themes. Starting from Kubrick, or any other pre-made theme, would be absurd. There is to much stuff there that would to be stripped out or fought against to be useful. So, I have my own. It&#8217;s been in a folder called BLANK-theme on my computer for a while, so I&#8217;m going to call it BLANK. And now I&#8217;m making it available for you. Read on to find out the scoop on it and you can decide if it would be of any use to you.</p>
<p><span id="more-981"></span></p>
<h3>What is BLANK?</h3>
<p>It is a WordPress theme with all the functionality of a typical WordPress theme but almost none of the styling. The idea is that when starting a new theme, it is far easier to use this as a base then a theme that is already finished and styled.</p>
<h3>What are some of it&#8217;s &#8220;features&#8221;?</h3>
<ul>
<li>Things are as semantically marked up as can be for a starter theme.</li>
<li>It&#8217;s XHTML 1.0 STRICT and validates. Maybe it will go HTML5 soon. We&#8217;re at that point where there isn&#8217;t a whole ton of advantages to going to HTML5 yet, but there aren&#8217;t many downsides either and it&#8217;s definitely the future.</li>
<li>The sidebar is widget-ready.</li>
<li>Page titles are optimized for best SEO and readability/usability.</li>
<li>Functions.php file does a number of things:  Sets up RSS &lt;link>&#8217;s in the head automatically, loads jQuery, removes the weird header links like rsd_link, wlw manifest, and generator info that I&#8217;ve never once needed, and registers the sidebar widget area.</li>
<li>Has some starter CSS ready to go, more about that below.</li>
<p>Uses <code>includes</code> for some key things, like under-title meta data and forward/back navigation, that are very common places for redundant code in themes.
</ul>
<h3>About the CSS</h3>
<p>As you can see from the screenshot above, the CSS is pretty baron, but not entirely! Here are some things the CSS is set up for:</p>
<ul>
<li>Uses a basic star-selector reset.</li>
<li>Includes a .group selector for the new clearfix</li>
<li>Has basic toolbox and WordPress-standard CSS classes, including .screen-reader-text for hiding things.</li>
<li>Standard typography-related sectors are there but generally without any attributes.</li>
<li>CSS for threaded comments is in there, but light on actual styling.</li>
<li>Both screen and print styles included in single stylesheet. Print styles optimized for generic nice printing.</li>
</ul>
<h3>Demo and Download</h3>
<p><img src="http://digwp.com/wp-content/blank-theme-example.jpg" width="590" height="475" alt="" title="" /></p>
<p>If you want to take a peak at it live, you can <a href="http://themeplayground.digwp.com/index.php?wptheme=BLANK%20Theme">view it in our Theme Playground</a>. You can also download it from there, or <a href="http://themeplayground.digwp.com/themes/BLANK/BLANK-Theme-v1.zip">directly right here</a>. </p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/02/blank-wordpress-theme/">Permalink</a> | <a href="http://digwp.com/2010/02/blank-wordpress-theme/#comments">52 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2010/02/blank-wordpress-theme/&title=BLANK WordPress&nbsp;Theme">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/theme/" title="View all posts in Theme" rel="category tag">Theme</a> | Tagged: <a href="http://digwp.com/tag/css/" rel="tag">CSS</a>, <a href="http://digwp.com/tag/free/" rel="tag">free</a>, <a href="http://digwp.com/tag/theme/" rel="tag">Theme</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/02/blank-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>52</slash:comments>
		</item>
		<item>
		<title>How to Widgetize Your WordPress Theme in 2&#160;Steps</title>
		<link>http://digwp.com/2010/02/how-to-widgetize-wordpress-theme/</link>
		<comments>http://digwp.com/2010/02/how-to-widgetize-wordpress-theme/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 17:47:30 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[widgets]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1379</guid>
		<description><![CDATA[Working on a new theme for the next Digging into WordPress book update, I found myself really getting into the whole &#8220;widgetizing&#8221; thing. Widgets enable non-technical users to customize your theme according to their specific layout needs, and with so many different widgets available, the possibilities are endless. You may have thought about widgets as [...]]]></description>
			<content:encoded><![CDATA[<p>Working on a new theme for the next Digging into WordPress book update, I found myself really getting into the whole &ldquo;widgetizing&rdquo; thing. Widgets enable non-technical users to customize your theme according to their specific layout needs, and with <a href="http://codex.wordpress.org/WordPress_Widgets" title="WordPress Widgets">so many</a> different widgets available, the possibilities are endless. You may have thought about widgets as something you do in the sidebar, but there is no reason to stop there. You can widgetize just about every part of your theme. In this post, we&rsquo;ll show you how to do widgetize your theme in <strong>two easy steps</strong>. Once we get the basics down, we&rsquo;ll dig into some <em>sweet tips and tricks</em>.</p>
<p><span id="more-1379"></span></p>
<h3>Widgetize Your WordPress Theme: Step 1</h3>
<p>Make a fist and howl at the monitor. Then place this code into your active theme&rsquo;s <code>functions.php</code> file:</p>
<pre><code>if (function_exists('register_sidebar')) {

	register_sidebar(array(
		'name' =&gt; 'Widgetized Area',
		'id'   =&gt; 'widgetized-area',
		'description'   =&gt; 'This is a widgetized area.',
		'before_widget' =&gt; '&lt;div id="%1$s" class="widget %2$s"&gt;',
		'after_widget'  =&gt; '&lt;/div&gt;',
		'before_title'  =&gt; '&lt;h4&gt;',
		'after_title'   =&gt; '&lt;/h4&gt;'
	));

}</code></pre>
<p>This is all that is needed for the first step. Once this widgetizing code is placed in your <code>functions.php</code> file, proceed to Step 2. The remainder of this section is explanation.</p>
<p>This code checks to make sure that the current version of WordPress supports widgets, and then declares an array of values that will be used to create the widgetized area in your theme. Here are the different values:</p>
<ul>
<li><code>name</code> &ndash; the name of the widgetized area as displayed in the <acronym title="WordPress">WP</acronym> Admin</li>
<li><code>id</code> &ndash; a unique identifier for your widgetized area</li>
<li><code>description</code> &ndash; description of the widgetized area</li>
<li><code>before_widget</code> &ndash; the markup generated before any user-added widgets</li>
<li><code>after_widget</code> &ndash; the markup generated after any user-added widgets</li>
<li><code>before_title</code> &ndash; the markup generated before the title of any user-added widgets</li>
<li><code>after_title</code> &ndash; the markup generated after the title of any user-added widgets</li>
</ul>
<p>So, given these parameters, our widgetizing code would result in the following output, say, if the built-in Search widget were added to our widgetized area:</p>
<pre><code>&lt;div id="search-3" class="widget widget_search"&gt;
	&lt;h4&gt;Search&lt;/h4&gt;
	&lt;form role="search" method="get" id="searchform" action="http://localhost/283/" &gt;
		&lt;div&gt;
			&lt;label class="screen-reader-text" for="s"&gt;Search for:&lt;/label&gt;
			&lt;input type="text" value="" name="s" id="s" /&gt;
			&lt;input type="submit" id="searchsubmit" value="Search" /&gt;
		&lt;/div&gt;
	&lt;/form&gt;
&lt;/div&gt;</code></pre>
<p>Note the markup created for the opening <code>&lt;div&gt;</code>, which gets its attribute information based on the wild-card matching specified in our widgetizing array. To see this more clearly, examine the following side-by-side comparison of the <code>sprintf</code> directives and the resulting <acronym title="(eXtensible) Hypertext Markup Language">(X)HTML</acronym> source code:</p>
<pre><code>'before_widget' =&gt; '&lt;div id="%1$s" class="widget %2$s"&gt;',
&lt;div id="search-3" class="widget widget_search"&gt;</code></pre>
<p>Hopefully the relationship is clear. This is a powerful way to ensure that all widgets have a similar class names and unique <acronym title="Identification">ID</acronym>s, which are important for easy <acronym title="Cascading Style Sheets">CSS</acronym> styles.</p>
<p>Let&rsquo;s continue with Step 2..</p>
<h3>Widgetize Your WordPress Theme: Step 2</h3>
<p>Finally, add the following code to the location in your theme&rsquo;s template file(s) where you would like the widgetized area to appear:</p>
<pre><code>&lt;div id="widgetized-area"&gt;

	&lt;?php if (function_exists('dynamic_sidebar') &amp;&amp; dynamic_sidebar('widgetized-area')) : else : ?&gt;

	&lt;div class="pre-widget"&gt;
		&lt;p&gt;&lt;strong&gt;Widgetized Area&lt;/strong&gt;&lt;/p&gt;
		&lt;p&gt;This panel is active and ready for you to add some widgets via the WP Admin&lt;/p&gt;
	&lt;/div&gt;

	&lt;?php endif; ?&gt;

&lt;/div&gt;</code></pre>
<p>With both steps complete, your theme should now feature a widgetized area in the location of your choosing. Nothing else needs to be done at this point. If you get it, then get to it and continue developing your theme. For more information and some juicy tips and tricks, continue reading.</p>
<p>Let&rsquo;s examine the code used in this second step. Everything located between the <code>if</code>/<code>endif</code> statements will be output to the browser when no widgets have been activated. This is a good place to inform the user that the area is widgetized and may be customized via the Widgets area in the WordPress Admin. I also include a &ldquo;<code>pre-widget</code>&rdquo; class to help style the pre-widget area. With multiple widgetized areas on a page, having a class name to hang styles on is super nice.</p>
<p>Also, note that we are using the <code>id</code> specified in the widgetizing array (refer to Step 1) as the parameter value for the specific <code>dynamic_sidebar()</code> check in the third line.</p>
<h3>Multiple widgetized areas</h3>
<p>So we now have a nice, widgetized sidebar. But why stop there? Implementing additional widgetized areas is as simple as replicating the code in Step 1 and Step 2. For example, let&rsquo;s say we wanted to widgetize the header, sidebar, and footer areas of our theme. We would be put this in our <code>functions.php</code> file:</p>
<pre><code>if (function_exists('register_sidebar')) {

	register_sidebar(array(
		'name' =&gt; 'Header',
		'id'   =&gt; 'header',
		'description'   =&gt; 'This is the widgetized header.',
		'before_widget' =&gt; '&lt;div id="%1$s" class="widget %2$s"&gt;',
		'after_widget'  =&gt; '&lt;/div&gt;',
		'before_title'  =&gt; '&lt;h4&gt;',
		'after_title'   =&gt; '&lt;/h4&gt;'
	));
	register_sidebar(array(
		'name' =&gt; 'Sidebar',
		'id'   =&gt; 'sidebar',
		'description'   =&gt; 'This is the widgetized sidebar.',
		'before_widget' =&gt; '&lt;div id="%1$s" class="widget %2$s"&gt;',
		'after_widget'  =&gt; '&lt;/div&gt;',
		'before_title'  =&gt; '&lt;h4&gt;',
		'after_title'   =&gt; '&lt;/h4&gt;'
	));
	register_sidebar(array(
		'name' =&gt; 'Footer',
		'id'   =&gt; 'footer',
		'description'   =&gt; 'This is the widgetized footer.',
		'before_widget' =&gt; '&lt;div id="%1$s" class="widget %2$s"&gt;',
		'after_widget'  =&gt; '&lt;/div&gt;',
		'before_title'  =&gt; '&lt;h4&gt;',
		'after_title'   =&gt; '&lt;/h4&gt;'
	));

}</code></pre>
<p>..and then we would place the following code chunks into their respective locations within our theme template files:</p>
<pre><code>&lt;div id="widgetized-header"&gt;

	&lt;?php if (function_exists('dynamic_sidebar') &amp;&amp; dynamic_sidebar('header')) : else : ?&gt;

	&lt;div class="pre-widget"&gt;
		&lt;p&gt;&lt;strong&gt;Widgetized Header&lt;/strong&gt;&lt;/p&gt;
		&lt;p&gt;This panel is active and ready for you to add some widgets via the WP Admin&lt;/p&gt;
	&lt;/div&gt;

	&lt;?php endif; ?&gt;

&lt;/div&gt;
&lt;div id="widgetized-sidebar"&gt;

	&lt;?php if (function_exists('dynamic_sidebar') &amp;&amp; dynamic_sidebar('sidebar')) : else : ?&gt;

	&lt;div class="pre-widget"&gt;
		&lt;p&gt;&lt;strong&gt;Widgetized Sidebar&lt;/strong&gt;&lt;/p&gt;
		&lt;p&gt;This panel is active and ready for you to add some widgets via the WP Admin&lt;/p&gt;
	&lt;/div&gt;

	&lt;?php endif; ?&gt;

&lt;/div&gt;
&lt;div id="widgetized-footer"&gt;

	&lt;?php if (function_exists('dynamic_sidebar') &amp;&amp; dynamic_sidebar('footer')) : else : ?&gt;

	&lt;div class="pre-widget"&gt;
		&lt;p&gt;&lt;strong&gt;Widgetized Footer&lt;/strong&gt;&lt;/p&gt;
		&lt;p&gt;This panel is active and ready for you to add some widgets via the WP Admin&lt;/p&gt;
	&lt;/div&gt;

	&lt;?php endif; ?&gt;

&lt;/div&gt;</code></pre>
<p>That&rsquo;s all there is to it. Of course, you&rsquo;ll probably want to tweak the details to suit your specific needs, but these two steps are all you need to widgetize your WordPress theme. Now let&rsquo;s wrap things up with some juicy widgetizing tricks..</p>
<h3>Some Juicy Widgetizing Tricks</h3>
<p>Here are some sweet little tips for widgetizing your theme:</p>
<h4>Streamline &amp; organize custom widgets</h4>
<p>The first thing that I do after widgetizing a new theme is to include a separate &ldquo;<code>widgets.php</code>&rdquo; that contains all of the custom widgets. A simple line of code is all that is required to acheive this functionality:</p>
<p><code>if ($wp_version &gt;= 2.8) require_once(TEMPLATEPATH.'/widgets.php');</code></p>
<p>Place that code into your <code>functions.php</code> file and place all of your widgets into a file called <code>widgets.php</code>. Once in place, this method will ensure that your widgets are loaded and available for all supportive versions of WordPress. This is a great way to keep your theme files nice and organized.</p>
<h4>Replace WordPress&rsquo; default widgets</h4>
<p>Many of the default WordPress widgets leave something to be desired. Fortunately, it&rsquo;s super-easy to override any of the default widgets with your own creations. For example, here is one way to replace the default Search Widget with your own version:</p>
<pre><code>&lt;?php function custom_search_widget() { ?&gt;

&lt;form action="http://localhost/283/index.php" method="get"&gt;
	&lt;div&gt;
		&lt;label for="s"&gt;Site Search&lt;/label&gt;
		&lt;input id="s" name="s" alt="Search" type="text" /&gt;
	&lt;/div&gt;
&lt;/form&gt;

&lt;?php } if (function_exists('register_sidebar_widget'))

register_sidebar_widget(__('Search'), 'custom_search_widget'); ?&gt;</code></pre>
<h4>Hide unused widget areas</h4>
<p>An empty widgetized area of your theme can look strange, especially when <acronym title="Cascading Style Sheets">CSS</acronym> styles are applied to the container element. To prevent this from happening, we can wrap each of our widgetized areas with the following code:</p>
<pre><code>&lt;?php if (function_exists('is_sidebar_active') &amp;&amp; is_sidebar_active('sidebar')) { ?&gt;

&lt;!-- code from Step 2 or whatever you want --&gt;

&lt;?php } ?&gt;</code></pre>
<p>With this conditional code, widgetized areas will only be displayed if they contain at least one active widget. Nice&nbsp;:) Also note that this conditional technique works for displaying things other than widgets.</p>
<h3>More..?</h3>
<p>Hopefully this easy two-step widgetizing guide will be useful for you during your next round of theme development. As always, if you know of any other sweet widgetizing tricks, please share them in the comments!</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/02/how-to-widgetize-wordpress-theme/">Permalink</a> | <a href="http://digwp.com/2010/02/how-to-widgetize-wordpress-theme/#comments">19 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2010/02/how-to-widgetize-wordpress-theme/&title=How to Widgetize Your WordPress Theme in 2&nbsp;Steps">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/php/" title="View all posts in PHP" rel="category tag">PHP</a>,  <a href="http://digwp.com/category/theme/" title="View all posts in Theme" rel="category tag">Theme</a> | Tagged: <a href="http://digwp.com/tag/php/" rel="tag">PHP</a>, <a href="http://digwp.com/tag/theme/" rel="tag">Theme</a>, <a href="http://digwp.com/tag/widgets/" rel="tag">widgets</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/02/how-to-widgetize-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Cool Things You can do with the WordPress &#8220;more&#8221;&#160;Tag</title>
		<link>http://digwp.com/2010/01/wordpress-more-tag-tricks/</link>
		<comments>http://digwp.com/2010/01/wordpress-more-tag-tricks/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 16:58:47 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Theme]]></category>
		<category><![CDATA[more-tag]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1185</guid>
		<description><![CDATA[Our personal collection of useful ways to customize and format the WordPress more tag&#8230;
Everyone who has been using WordPress for any length of time should be familiar with the &#60;!--more--&#62; tag. When you are writing a post, inserting the &#60;!--more--&#62; tag within the post text will create an excerpt out of any text/markup that precedes [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Our personal collection of useful ways to customize and format the WordPress <code>more</code> tag&#8230;</p></blockquote>
<p>Everyone who has been using WordPress for any length of time should be familiar with the <code>&lt;!</code><code>--more--&gt;</code> tag. When you are writing a post, inserting the <code>&lt;!</code><code>--more--&gt;</code> tag within the post text will create an excerpt out of any text/markup that precedes it. The post will then show the default &ldquo;<a href="#">more&#8230;</a>&rdquo; link that readers may click to view the entire post. When the <code>more</code> tag is used, the post&rsquo;s excerpt will be displayed on all non-single views, such as category, tag, and archive views; the entire post content will only be displayed when the single-post view is displayed. Let&rsquo;s look at a quick example..</p>
<p><span id="more-1185"></span></p>
<h3>A quick example of how to use the <code>more</code> tag</h3>
<p><strong>If you have the following post text:</strong></p>
<pre><code>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. 
Quisque volutpat mattis eros. Nullam malesuada erat ut turpis mattis.
Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.

&lt;!-more-&gt;

Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer 
ligula vulputate sem tristique cursus. Nam nulla quam, gravida non dolor, 
commodo a semper suscipit, sodales sit amet, nisi adipiscing.</code></pre>
<p><strong>..your post will show this on all non-single post views:</strong></p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio.<br />
Quisque volutpat mattis eros. Nullam malesuada erat ut turpis mattis.<br />
Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p>
<p><a href="#">more&#8230;</a></p>
<p><strong>..and this on all single-post views:</strong></p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio.<br />
Quisque volutpat mattis eros. Nullam malesuada erat ut turpis mattis.<br />
Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p>
<p>Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer<br />
ligula vulputate sem tristique cursus. Nam nulla quam, gravida non dolor,<br />
commodo a semper suscipit, sodales sit amet, nisi adipiscing.</p>
<p>..which basically shows the entire post <em>without</em> the <code>more</code> link.</p>
<h3>Why do we use the <code>more</code> tag?</h3>
<p>Well mostly because excerpts are cool, and you can display many of them on your home page to give visitors a good overview of your content without making them scroll forever to do so. If one of your excerpts catches the visitor&rsquo;s eye, they will most likely want to read the entire post, and can do so by clicking on the link created by the <code>more</code> tag. To help encourage this behavior, there are several ways to customize the <code>more</code> link text, depending on your specific design goals. Let&rsquo;s take a look..</p>
<h3>Customize the <code>more</code> link text on a post-by-post basis</h3>
<p>There are a couple of good ways to customize the output format of your <code>more</code> link text. By far, the easiest way is to simply include your custom text right there in the <code>more</code> tag within your post text. For example, if you wanted to change your <code>more</code> text from the default to &ldquo;Keep reading this post&rdquo;, you would replace the usual <code>&lt;!</code><code>--more--&gt;</code> tag with this:</p>
<pre><code>&lt;!--more Keep reading this post--&gt;</code></pre>
<p>This way, WordPress makes it easy to customize <em>any</em> post&rsquo;s <code>more</code> link with unique text. This is one of those sweet WordPress secrets that not many people know about, as evidenced by the popular alternative method for customizing per-post <code>more</code> text:</p>
<pre><code>&lt;?php $custom_more = get_post_meta($post-&gt;ID, "custom_more_text", true);
if(!$custom_more) { $custom_more = "Keep reading this post &amp;raquo;"; }
the_content($custom_more); ?&gt;</code></pre>
<p>This code looks for a custom field named &ldquo;<code>custom_more_text</code>&rdquo; and displays its value as the post&rsquo;s custom <code>more</code> text. But again, this is complete overkill thanks to the previous method.</p>
<h3>Customize the <code>more</code> link text on a sitewide basis</h3>
<p>Instead of customizing <em>individual</em> <code>more</code> text, we can also customize it for <em>all</em> posts on a sitewide basis. The first and easiest way to change the default <code>more</code> link text is to simply add your custom text to <code>the_content()</code> template tag:</p>
<pre><code>&lt;?php the_content('Keep reading this post'); ?&gt;</code></pre>
<p>You can even add markup to help format and style the output according to your needs:</p>
<pre><code>&lt;?php the_content("&lt;span class="custom-more"&gt;Keep reading this post&lt;/span&gt;"); ?&gt;</code></pre>
<p>I think most WordPress peeps are familiar with this method and use it frequently. But there is also a newer method for accomplishing the same thing from the <code>functions.php</code> file. As of WordPress 2.8, we now may filter sitewide <code>more</code> links using the new filter hook, <code>the_content_more_link</code>:</p>
<pre><code>function my_more_link($more_link, $more_link_text) {
	return str_replace($more_link_text, 'Keep reading this post', $more_link);
}
add_filter('the_content_more_link', 'my_more_link', 10, 2);</code></pre>
<p>That goes into your theme&rsquo;s <code>functions.php</code> file. Simply edit the &ldquo;<code>Keep reading this post</code>&rdquo; string to whatever you would like to use for your custom <code>more</code> text. This is a good way to change your theme&rsquo;s <code>more</code> text without modifying any theme template files &#8212; perfect for customization via child themes! <a href="http://justintadlock.com/archives/2009/07/01/how-to-filter-a-wordpress-themes-more-link-text" title="How to filter a WordPress theme’s 'more link' text">Check out Justin Tadlock&rsquo;s article for more information</a>.</p>
<h3>Automatically display the post title in <code>more</code> links</h3>
<p>Another cool <code>more</code>-tag trick is to include the post title in the <code>more</code> link text. For example, we might want to setup something like this:</p>
<p>Lorem ipsum..</p>
<p><a href="#">Continue reading &ldquo;Lorem Ipsum Strikes Back&rdquo;</a></p>
<p>Including the post title into your <code>more</code> links is a great way to personalize each excerpt with a little &ldquo;more&rdquo; (haha). Anyway, here is how the Codex suggests doing this:</p>
<pre><code>&lt;?php the_content("...continue reading the story called " . get_the_title('', '', false)); ?&gt;</code></pre>
<p>That&rsquo;ll work, but we can clean it up a little like so:</p>
<pre><code>&lt;?php the_content(the_title('Continue reading &amp;ldquo;','&amp;rdquo;',false)); ?&gt;</code></pre>
<p>That&rsquo;s a tight little snippet that will generate custom <code>more</code> links that include the title of the associated post. Nice.</p>
<h3>Stop <code>more</code> link from jumping to middle of page</h3>
<p>By default, clicking on the <code>more</code> link will take the reader to the single-post view <strong>at the location where the <code>more</code> tag is specified in the source code</strong>. Thus, if you are using default <code>more</code>-tag functionality, your visitors are being thrown halfway-down your post after clicking on the <code>more</code> link. At one time, this seemed like a good idea, but the convention is now to simply open the post-view without jumping to any particular point in the page. </p>
<p>All of that to say this: if you want the <code>more</code> link to open the post-view at the <em>top</em> of the page, slap this little gem into your active theme&rsquo;s <code>functions.php</code> file:</p>
<pre><code>function remove_more_jump_link($link) { 
	$offset = strpos($link, '#more-');
	if ($offset) {
		$end = strpos($link, '"',$offset);
	}
	if ($end) {
		$link = substr_replace($link, '', $offset, $end-$offset);
	}
	return $link;
}
add_filter('the_content_more_link', 'remove_more_jump_link');</code></pre>
<p>This will kill the <code>more</code> &ldquo;jump&rdquo; and keep visitors from being thrown around the page unexpectedly. Note that this function is only for WordPress version 2.8 and better. For older versions, you&rsquo;re gonna need to hack the core. See the <a href="http://codex.wordpress.org/Customizing_the_Read_More/#Link_Jumps_to_More_or_Top_of_Page" title="Customizing the Read More: Link Jumps to More or Top of Page">Codex</a> for more information.</p>
<h3>Target custom pages with the <code>more</code> tag</h3>
<p>The typical use of the <code>more</code> tag is such that its link opens the single-view of the associated post. This may be changed, however, should you ever need to target a different web page. To understand this a bit better, consider the parameters available to <code>the_content()</code> template tag:</p>
<pre><code>&lt;?php the_content($more_link_text, $strip_teaser, $more_file); ?&gt;</code></pre>
<p>Here, the <code>$more_link_text</code> parameter defines the text that will be used for the <code>more</code> link. The <code>$strip_teaser</code> parameter defines a boolean value determining whether or not to display the <code>more</code> link. The third parameter is the one we&rsquo;re interested in here. The <code>$more_file</code> parameter specifies the <acronym title="Uniform Resource Locator">URL</acronym> that the <code>more</code> link should reference. By default, this <acronym title="Uniform Resource Locator">URL</acronym> points to the associated single-view post, but we could just as easily customize this like so:</p>
<pre><code>&lt;?php the_content('Order Now!', FALSE, 'http://amazing-product.com/order-page.html'); ?&gt;</code></pre>
<p>Or whatever. Obviously, the uses for this are limited, but it&rsquo;s there if you ever need it.</p>
<h3>Styling the <code>more</code> link</h3>
<p>The easiest way to style the <code>more</code> tag is to take advantage of the built-in class attribute, <code>more-link</code>. By default, this class is automatically included on every WordPress <code>more</code> link in the entire world. Thus, you can apply styles directly, for example:</p>
<pre><code>.more-link {
	border: thin solid black;
	letter-spacing: 1px;
	background: yellow;
	font-size: 24px;
	color: red;
	}</code></pre>
<p>If you need additional control, you may also incorporate custom markup to your <code>more</code> link via <code>the_content()</code> template tag:</p>
<pre><code>&lt;?php the_content("&lt;span class="custom-more"&gt;Keep reading &lt;em&gt;this&lt;/em&gt; post&lt;/span&gt;"); ?&gt;</code></pre>
<p>Which would output markup such that the following <acronym title="Cascading Style Sheets">CSS</acronym> could be applied:</p>
<pre><code>.custom-more {
	font-weight: bolder;
	}
	.custom-more em {
		font-weight: normal;
		font-style: italic;
		}</code></pre>
<p>Obviously, this is just a simple example to help illustrate the method. Just about anything is possible!</p>
<h3>Adding an image to your <code>more</code> link</h3>
<p>Last but not least, let&rsquo;s wrap up the article with a couple of ways to add an image to your <code>more</code> link. The first way to do it is to simply include the image element directly in <code>the_content()</code> template tag:</p>
<pre><code>&lt;?php the_content('&lt;img src="http://domain.tld/read-more.png" alt="Arrow" title="Read more" /&gt;'); ?&gt;</code></pre>
<p>This will spit out an image for your more tag instead of text. You could also add in some text, but if you don&rsquo;t be sure to include the <code>alt</code> and <code>title</code> attributes for the <code>&lt;img&gt;</code> element. Either way, you can also style your &ldquo;Read more&rdquo; image using some <acronym title="Cascading Style Sheets">CSS</acronym>, or even bypass the <code>&lt;img&gt;</code> element completely and add an image using a few lines of <acronym title="Cascading Style Sheets">CSS</acronym>:</p>
<pre><code>.more-link img {
	background:url(http://domain.tld/read-more.png) no-repeat left center;
	padding: 10px;
	height: 100px;
	width: 300px;
	}</code></pre>
<p>Again, just an example demonstrating how it works. The possibilities here are virtually infinite.</p>
<h3>&ldquo;I give myself a B+&rdquo;</h3>
<p>It would have been an &ldquo;A&rdquo;, but I just <em>know</em> there are <em>more</em> cool things you can do with the WordPress <code>more</code> tag. This article shares all of the cool tricks that we know, but there&rsquo;s just <em>got</em> to be <strong>more</strong> sweet tips! Hopefully you know of some more <code>more</code> tricks to share with the WordPress community&nbsp;;) &ndash; Chime in!</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/01/wordpress-more-tag-tricks/">Permalink</a> | <a href="http://digwp.com/2010/01/wordpress-more-tag-tricks/#comments">24 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2010/01/wordpress-more-tag-tricks/&title=Cool Things You can do with the WordPress &#8220;more&#8221;&nbsp;Tag">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/theme/" title="View all posts in Theme" rel="category tag">Theme</a> | Tagged: <a href="http://digwp.com/tag/more-tag/" rel="tag">more-tag</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/01/wordpress-more-tag-tricks/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>How to Develop WordPress Themes Behind the&#160;Scenes</title>
		<link>http://digwp.com/2009/12/develop-themes-behind-the-scenes/</link>
		<comments>http://digwp.com/2009/12/develop-themes-behind-the-scenes/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 07:16:07 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[theme-switch]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1104</guid>
		<description><![CDATA[A reader recently asked about how to develop a theme on a live site such that:

All visitors will see the current theme
Only the designer will see the new theme
All site plugins will work with the new theme
Smooth transition between old and new theme at launch

These are the main concerns, but there are a few other [...]]]></description>
			<content:encoded><![CDATA[<p>A reader recently asked about how to develop a theme on a live site such that:</p>
<ul>
<li>All visitors will see the current theme</li>
<li>Only the designer will see the new theme</li>
<li>All site plugins will work with the new theme</li>
<li>Smooth transition between old and new theme at launch</li>
</ul>
<p>These are the main concerns, but there are a few other details that need addressed to ensure smooth theme development on a live site. Let&rsquo;s take a look at how to achieve these goals and effectively develop themes behind the scenes..</p>
<p><span id="more-1104"></span></p>
<h3>You need a plugin</h3>
<p>The easiest way to develop a new theme behind the scenes is to install a good theme-switcher plugin. There are plenty available:</p>
<ul>
<li><a href="http://wordpress.org/extend/plugins/theme-switcher/" title="Theme Switcher">Theme Switcher</a></li>
<li><a href="http://wordpress.org/extend/plugins/theme-switcher-reloaded/" title="Theme Switcher Reloaded">Theme Switcher Reloaded</a></li>
<li><a href="http://wordpress.org/extend/plugins/alternative-theme-switcher/" title="Alternative Theme Switcher">Alternative Theme Switcher</a></li>
<li><a href="http://wordpress.org/extend/plugins/theme-preview/" title="Theme Preview">Theme Preview</a>
<li><a href="http://wordpress.org/extend/plugins/theme-test-drive/" title="Theme Test Drive">Theme Test Drive</a></li>
<li><a href="http://wordpress.org/extend/plugins/nkthemeswitch/" title="Theme Switch and Preview">NK Theme Switch</a></li>
</ul>
<p>Any of these plugins will work fine for the purposes of working with multiple themes on your site. If you also plan on enabling your visitors to switch themes, I would have to recommend the newer NK Theme Switch plugin. NK Theme Switch does everything the other plugins can do, but with the added bonus that it redirects users back to the page from which they came after switching themes. The other two plugins switch themes, but the user is always redirected back to the home page after the theme switch. </p>
<p>Note that, for the different theme-switcher plugins, the <acronym title="Uniform Resource Locator">URL</acronym>s used when switching themes include different query-string parameters that are similar but not interchangeable. Once you implement a theme switcher, replacing it with a different plugin is going to be difficult.</p>
<p>In any case, once you have your theme-switcher plugin of choice activated, you&rsquo;re going to need to know how to actually switch the themes..</p>
<h3>Switching themes</h3>
<p>Different plugins involve different methods of switching to a different theme. If you are using NK Theme Switch, you can select and activate your alternate (development) theme from within the WordPress Admin. This is the <em>easiest</em> way to do it. If you are using one of the other theme-switching plugins, activating the alternate theme for your browser is as easy as entering a specific <acronym title="Uniform Resource Locator">URL</acronym> into the address bar. These theme-switching <acronym title="Uniform Resource Locator">URL</acronym>s look similar for either of the first two plugins:</p>
<pre><code>http://domain.tld/index.php?wptheme=ThemeName</code></pre>
<p>For example, here is the <acronym title="Uniform Resource Locator">URL</acronym> used to switch to one of my favorite themes at <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a>:</p>
<pre><code>http://perishablepress.com/press/index.php?wptheme=Perishable</code></pre>
<p>The syntax here is straightforward &#8212; the only thing that needs to be changed is the theme name, which in this case is &ldquo;Perishable&rdquo;. When developing a new theme for Perishable Press, I simply jot down the theme-switch <acronym title="Uniform Resource Locator">URL</acronym> for both the new theme and the active default theme. This makes jumping back and forth very easy. Of course, the general format of these <acronym title="Uniform Resource Locator">URL</acronym>s will vary depending on the particular theme-switching plugin that you use.</p>
<p>Another option for switching between current and alternate themes is to actually include the theme-switching links and/or dropdown menu right there on the theme pages themselves. For example, including the theme-switch dropdown menu in the footer of all your themes is a great way to speed up and simplify the development process. But be advised, unless you explicitly <em>exclude</em> your new theme from the theme-switch menu, it will be available for all of your visitors to see and activate. The other method of just using the <acronym title="Uniform Resource Locator">URL</acronym> directly is a good way to ensure privacy.</p>
<p>Now that you are setup and easily switching between themes, there are a few other points to consider..</p>
<h3>Your new theme is just another theme</h3>
<p>This may sound strange, but there is nothing special about your new theme &#8212; it&rsquo;s treated by WordPress as any other theme in your &ldquo;<code>themes</code>&rdquo; directory. All of the requirements of the default theme apply:</p>
<ul>
<li>Your new theme needs a properly configured <code>style.css</code> file</li>
<li>Your new theme needs a working <code>index.php</code> file</li>
</ul>
<p>Assuming your new theme meets these basic requirements, WordPress will recognize your theme as such and display it when activated (either through the Admin or via theme-switch plugin). Incidentally, the name of your theme is specified via the <code>style.css</code> file. The &ldquo;<code>Theme Name</code>&rdquo; that is listed here will be the same one used in your theme-switching <acronym title="Uniform Resource Locator">URL</acronym>s.</p>
<p>Once you get the basics of your new theme established, use your theme-switching plugin to activate it locally in your browser. Form there, you can rock the design however you want, exactly as you would do when starting from a fresh installation of WordPress. While you are working on your new theme, your visitors will still be seeing your default active theme, which is whatever you specify in the WordPress Admin. This is why the theme-switch development method works so well.</p>
<h3>Pages, plugins, and custom functions</h3>
<p>Here are a few more little things that will help you when developing your themes behind the scenes..</p>
<dl>
<dt>Plugins affect <em>all</em> themes</dt>
<dd>Even when your theme is not set as the current default, it will still be affected by all of the plugins installed on your site. This is one of the benefits of using plugins over custom functions..</dd>
<dt>Custom functions only affect the theme being used</dt>
<dd>In contrast to plugins, custom functions (i.e., functions placed in your theme&rsquo;s <code>functions.php</code> file) only affect the current theme being viewed. If you seem to missing some functionality in your &ldquo;behind-the-scenes&rdquo; theme, make sure that you have properly transferred any required custom functions.</dd>
<dt>Page templates will confuse you</dt>
<dd>This happens to everyone: you are working behind the scenes on a new theme and you can&rsquo;t seem to get a custom page template to appear in the WordPress Admin. This is because the page editor only shows the templates available to the current default active theme (i.e., the one that <em>everyone</em> sees). To work around this, you can either upload a copy of the custom page template to the active theme, or temporarily switch the default active theme to your behind-the-scenes theme. Personally, I use the former method and just delete the page template if it&rsquo;s not needed in the default theme.</dd>
</dl>
<p>And last but not least..</p>
<h3>Prepare for launch!</h3>
<p>Once you have your new theme pimped out and ready to go, simply change your default active theme in the WordPress Admin to launch it for the world see. That&rsquo;s all there is to it!&nbsp;:)</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/12/develop-themes-behind-the-scenes/">Permalink</a> | <a href="http://digwp.com/2009/12/develop-themes-behind-the-scenes/#comments">27 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2009/12/develop-themes-behind-the-scenes/&title=How to Develop WordPress Themes Behind the&nbsp;Scenes">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/design/" title="View all posts in Design" rel="category tag">Design</a>,  <a href="http://digwp.com/category/theme/" title="View all posts in Theme" rel="category tag">Theme</a> | Tagged: <a href="http://digwp.com/tag/plugin/" rel="tag">plugin</a>, <a href="http://digwp.com/tag/theme-switch/" rel="tag">theme-switch</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/12/develop-themes-behind-the-scenes/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Display Gravatar &amp; Autofill Fields for Previous&#160;Commenter</title>
		<link>http://digwp.com/2009/12/gravatar-and-auto-fill/</link>
		<comments>http://digwp.com/2009/12/gravatar-and-auto-fill/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 14:24:22 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Theme]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1063</guid>
		<description><![CDATA[When someone comments on your site, cookies with the information the entered are saved to their computers. WordPress makes it easy to access that information. In fact, in your comments.php template they are ready-to-go PHP variables you can spit out anywhere you&#8217;d like. Let&#8217;s take a look.

Here are the most important ones, when it comes [...]]]></description>
			<content:encoded><![CDATA[<p>When someone comments on your site, cookies with the information the entered are saved to their computers. WordPress makes it easy to access that information. In fact, in your comments.php template they are ready-to-go PHP variables you can spit out anywhere you&#8217;d like. Let&#8217;s take a look.</p>
<p><span id="more-1063"></span></p>
<p>Here are the most important ones, when it comes to commenting, are these:</p>
<ul>
<li>$comment_author</li>
<li>$comment_author_email</li>
<li>$comment_author_url</li>
</ul>
<p>Which you can safely output anywhere in the comments.php file like so:</p>
<pre><code>&lt;?php echo esc_attr($comment_author); ?&gt;
&lt;?php echo esc_attr($comment_author_email); ?&gt;
&lt;?php echo esc_attr($comment_author_url); ?&gt;</code></pre>
<p>In order to pre-fill the comment form with this information, the inputs for your comment form could be marked up like so:</p>
<pre><code>&lt;div&gt;
  &lt;label for="author"&gt;Name*&lt;/label&gt;
  &lt;input type="text" name="author" id="author" value="&lt;?php echo esc_attr($comment_author); ?&gt;" tabindex="1" /&gt;			
&lt;/div&gt;	

&lt;div&gt;
  &lt;label for="email"&gt;Email*&lt;/label&gt;
  &lt;input type="text" name="email" id="email" value="&lt;?php echo esc_attr($comment_author_email); ?&gt;" tabindex="2" /&gt;
&lt;/div&gt;

&lt;div&gt;
  &lt;label for="url"&gt;Website&lt;/label&gt;
  &lt;input type="text" name="url" id="url" value="&lt;?php echo esc_attr($comment_author_url); ?&gt;" tabindex="3" /&gt;
&lt;/div&gt;</code></pre>
<h3>Getting the Gravatar</h3>
<p>Gravatars are those little pictures that show up next to comments&#8230; &#8220;Globally Recognized Avatars&#8221;. Anybody can have one, <a href="http://en.gravatar.com/">get one here</a>. What is cool about Gravatars is you have your own account that is associated with your email, so anywhere you comment that you use that email that supports Gravatars, that image will show up, and you can &#8220;globally&#8221; change that image at any time. </p>
<p>It is almost trivially easy to grab the URL source of someone&#8217;s Gravatar. The direct link to the image is:</p>
<p>http://www.gravatar.com/avatar/MD5-HASH-OF-EMAIL</p>
<p>So to spit out an &lt;img&gt; in your comments.php file, use a little PHP:</p>
<pre><code>&lt;?php if ($comment_author_email != "") { 

    $gravatar_link = 'http://www.gravatar.com/avatar/' . md5($comment_author_email) . '?s=32';
    echo '&lt;img src="' . $gravatar_link . '" alt="" /&gt;';

} ?&gt;</code></pre>
<p>On CSS-Tricks, I use all of this to prefill previous commenter information, including a small Gravatar:</p>
<p><img src="http://digwp.com/wp-content/blog-images/prefill.png" width="558" height="86" alt="" title="" /></p>
<p>That&#8217;s all there is to it!  I think the comment form in every single WordPress theme ever written should probably use at least the pre-fill stuff. The &#8220;default&#8221; and &#8220;classic&#8221; themes that come with WordPress have this, so it&#8217;s pretty standard, but I do see plenty of themes that don&#8217;t.</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/12/gravatar-and-auto-fill/">Permalink</a> | <a href="http://digwp.com/2009/12/gravatar-and-auto-fill/#comments">9 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2009/12/gravatar-and-auto-fill/&title=Display Gravatar &#038; Autofill Fields for Previous&nbsp;Commenter">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/theme/" title="View all posts in Theme" rel="category tag">Theme</a> | Tagged: <a href="http://digwp.com/tag/comments/" rel="tag">comments</a>, <a href="http://digwp.com/tag/php/" rel="tag">PHP</a>, <a href="http://digwp.com/tag/theme/" rel="tag">Theme</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/12/gravatar-and-auto-fill/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Redirect Mobile Users to a Mobile WordPress&#160;Theme</title>
		<link>http://digwp.com/2009/12/redirect-mobile-users-to-mobile-theme/</link>
		<comments>http://digwp.com/2009/12/redirect-mobile-users-to-mobile-theme/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 13:57:04 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Theme]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1032</guid>
		<description><![CDATA[Let&#8217;s say you want to have a special theme for your WordPress site for mobile users. You don&#8217;t want to use a pre-canned solution or anything third-party, you just want to create and design the theme yourself. So what you need to happen is for the site to detect mobile users and server up an [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s say you want to have a special theme for your WordPress site for mobile users. You don&#8217;t want to use a pre-canned solution or anything third-party, you just want to create and design the theme yourself. So what you need to happen is for the site to detect mobile users and server up an alternate theme instead. Here is how I might do it.</p>
<p><span id="more-1032"></span></p>
<h3>1. Detect for mobiles</h3>
<p>You could do it by <a href="http://css-tricks.com/snippets/javascript/redirect-mobile-devices/">measuring screen size with JavaScript</a>, but that&#8217;s probably not the most solid technique. It can also be done server side with PHP, <a href="http://detectmobilebrowsers.mobi/">check out this project</a> for doing so. Using that code, you could use something like this at the top of your header.php file:</p>
<pre><code>include('mobile_device_detect.php');
$mobile = mobile_device_detect();

if ($mobile==true) {
  // This is a mobile device
} else {
 // This is NOT a mobile device, it's a full-featured browser
}</code></pre>
<h3>2. Install the Theme Switch plugin</h3>
<p>It is available <a href="http://wordpress.org/extend/plugins/nkthemeswitch/">here</a>. This is a sweet plugin for a variety of reasons. I like using it for developing themes right on live sites. We&#8217;ll use it in a different application here though. What the plugin does is create special URLs for your site that activate different themes. </p>
<p>http://your-website.com/?theme=Your_Mobile_Theme</p>
<h3>3. Combine</h3>
<p>Now you can test for mobiles, then redirect to a special theme-switching URL to activate your mobile theme:</p>
<pre><code>include('mobile_device_detect.php');
$mobile = mobile_device_detect();

if ($mobile==true) {
  header( 'Location: http://your-website.com/?theme=Your_Mobile_Theme' ) ;
} else {
 // Do nothing, regular browser.
}</code></pre>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/12/redirect-mobile-users-to-mobile-theme/">Permalink</a> | <a href="http://digwp.com/2009/12/redirect-mobile-users-to-mobile-theme/#comments">23 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2009/12/redirect-mobile-users-to-mobile-theme/&title=Redirect Mobile Users to a Mobile WordPress&nbsp;Theme">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/theme/" title="View all posts in Theme" rel="category tag">Theme</a> | Tagged: <a href="http://digwp.com/tag/mobile/" rel="tag">mobile</a>, <a href="http://digwp.com/tag/php/" rel="tag">PHP</a>, <a href="http://digwp.com/tag/theme/" rel="tag">Theme</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/12/redirect-mobile-users-to-mobile-theme/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>How to Import and Display Feeds in WordPress 2.8 and&#160;Beyond</title>
		<link>http://digwp.com/2009/11/import-and-display-feeds-in-wordpress/</link>
		<comments>http://digwp.com/2009/11/import-and-display-feeds-in-wordpress/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 17:02:47 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Theme]]></category>
		<category><![CDATA[feeds]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=961</guid>
		<description><![CDATA[Importing and displaying feeds in your WordPress themes is a great way to share additional content with your readers. Some good examples include:

Displaying your latest tweets, flickrs, or delicious saves
Displaying content from your other sites in your sidebar or footer
Providing a public link feed to which your readers may contribute or subscribe

Basically, anything that is [...]]]></description>
			<content:encoded><![CDATA[<p>Importing and displaying feeds in your WordPress themes is a great way to share additional content with your readers. Some good examples include:</p>
<ul>
<li>Displaying your latest tweets, flickrs, or delicious saves</li>
<li>Displaying content from your other sites in your sidebar or footer</li>
<li>Providing a public link feed to which your readers may contribute or subscribe</li>
</ul>
<p>Basically, anything that is available in any sort of feed format &#8212; <acronym title="Really Simple Syndication">RSS</acronym>, <acronym title="eXensible Markup Lanuage">XML</acronym>, Atom, etc. &#8212; may be easily imported and displayed on your WordPress-powered site.</p>
<p><span id="more-961"></span></p>
<p>Prior to version 2.8, WordPress used Magpie and Snoopy functionality to make it easy to parse and display feeds. As described in my previous article on <a href="http://perishablepress.com/press/2009/04/26/import-and-display-rss-feeds-in-wordpress/" title="Import and Display RSS Feeds in WordPress">importing and displaying feeds in WordPress</a>, including a feed using the built-in Magpie class is straightforward:</p>
<pre><code>&lt;?php include_once(ABSPATH.WPINC.'/rss.php');
wp_rss('http://domain.tld/your-feed/', 7); ?&gt;</code></pre>
<p>This code example will import and display the feed of your choice in WordPress versions 2.7 and older. For versions 2.8 and 2.9 (and possibly beyond), WordPress has changed from Magpie and Snoopy to SimplePie and FeedCache for retrieval, parsing and automatic caching of feeds. This is a good thing, even though SimplePie ceased development shortly after it was adopted by WordPress. Hopefully someone will pick it up and run with it.</p>
<p>For now, we just want to use WordPress to display external feeds on our sites. To do this, WordPress gives us the new <code>fetch_feed()</code> function, which retrieves, parses, and caches <em>any</em> <acronym title="Really Simple Syndication">RSS</acronym> feed, even those generated by your own installation of WordPress.</p>
<p>To use this new function, we begin with a compatibility check, just in case we&rsquo;re running an older version of WordPress. If the function exists, we proceed by including the required file, <code>feed.php</code>. Then, once we have the required file, we specify the feed <acronym title="Uniform Resource Identifier">URI</acronym> as the (only) parameter of the <code>fetch_feed</code> function:</p>
<pre><code>&lt;?php if(function_exists('fetch_feed')) {

	include_once(ABSPATH . WPINC . '/feed.php');  // include the required file
	$feed = fetch_feed('http://digwp.com/feed/'); // specify the source feed

} ?&gt;</code></pre>
<p>At this point, all of the <acronym title="eXtensible Markup Language">XML</acronym> data from our source feed is returned as a standard SimplePie object that we capture as a variable called &ldquo;<code>$feed</code>&rdquo;. With the feed data cached and ready, we may use a variety of SimplePie methods to manipulate and display the data according to our needs.</p>
<p>The first thing that we may want to do is specify the number of items to display:</p>
<pre><code>$limit = $feed-&gt;get_item_quantity(7); // specify number of items</code></pre>
<p>Here we are showing seven items, but you can choose any number you want. Next, we want to create an array containing all of our feed items so that we can then loop through it and display stuff like the title, the date, the post contents, and so on. Here is how we create our array of seven items:</p>
<pre><code>$items = $feed-&gt;get_items(0, $limit); // create an array of items</code></pre>
<p>Note that the first feed item is numbered zero (&ldquo;<code>0</code>&rdquo;) and the last feed item is specified by the previously declared <code>$limit</code> variable, so we know <em>exactly</em> how many items to include in the array.</p>
<p>At this point, we are ready to loop through the array and display data from each of our feed items. Before we do, however, we want to ensure that the feed isn&rsquo;t empty. Once this is verified, we proceed to loop through each item and display its title, permalink <acronym title="Uniform Resource Locator">URL</acronym>, and post date:</p>
<pre><code>&lt;ul&gt;

   &lt;?php if ($limit == 0) { ?&gt;

   &lt;li&gt;The feed is either empty or unavailable.&lt;/li&gt;

   &lt;?php } else { foreach ($items as $item) : ?&gt;

   &lt;li&gt;
      &lt;a href="&lt;?php echo $item-&gt;get_permalink(); ?&gt;" title="&lt;?php echo $item-&gt;get_date('j F Y @ g:i a'); ?&gt;"&gt;
         &lt;?php echo $item-&gt;get_title(); ?&gt;
      &lt;/a&gt;
   &lt;/li&gt;

   &lt;?php endforeach; } ?&gt;

&lt;/ul&gt;</code></pre>
<p>Not bad, but what about post content? In addition to the post title, date, and permalink, it&rsquo;s useful to be able to display an actual snippet from each feed item. No problem, just add the following method to your feed loop:</p>
<pre><code>&lt;?php echo $item-&gt;get_description(); ?&gt;</code></pre>
<p>You can also display the title of the feed itself with this snippet:</p>
<pre><code>&lt;?php echo $feed-&gt;get_title(); ?&gt;</code></pre>
<p>Of course, there are many more types of data that may be extracted and displayed from your feed items. For more information, check the references at the end of this article.</p>
<p>For now, allow me to wrap things up by putting everything together into a nice, plug-&amp;-play, copy-&amp;-paste code snippet that is perfect for importing and displaying feed items on your WordPress-powered site:</p>
<pre><code>&lt;?php if(function_exists('fetch_feed')) {

	include_once(ABSPATH . WPINC . '/feed.php');               // include the required file
	$feed = fetch_feed('http://feeds.feedburner.com/jquery/'); // specify the source feed

	$limit = $feed-&gt;get_item_quantity(7); // specify number of items
	$items = $feed-&gt;get_items(0, $limit); // create an array of items

}
if ($limit == 0) echo '&lt;div&gt;The feed is either empty or unavailable.&lt;/div&gt;';
else foreach ($items as $item) : ?&gt;

&lt;div&gt;
	&lt;a href="&lt;?php echo $item-&gt;get_permalink(); ?&gt;" 
	  title="&lt;?php echo $item-&gt;get_date('j F Y @ g:i a'); ?&gt;"&gt;
		&lt;?php echo $item-&gt;get_title(); ?&gt;
	&lt;/a&gt;
&lt;/div&gt;
&lt;div&gt;
	&lt;?php echo substr($item-&gt;get_description(), 0, 200); ?&gt; 
	&lt;span&gt;[...]&lt;/span&gt;
&lt;/div&gt;

&lt;?php endforeach; ?&gt;</code></pre>
<p>This is the code that I use on my new site, <a href="http://jquery-mix.com/" title="Everything jQuery on the Web">jQuery Mix</a>. It displays the following information:</p>
<ul>
<li>Seven items from the jQuery.com feed</li>
<li>Permalink, date, and title for each item</li>
<li>First 200 characters of each item&rsquo;s post content</li>
</ul>
<p>This code snippet seems to work great and should be easy to customize to fit your specific needs. Check the docs for more information!</p>
<h3>References</h3>
<ul>
<li><a href="http://simplepie.org/wiki/">SimplePie Documentation</a></li>
<li><a href="http://simplepie.org/wiki/reference/start">SimplePie Function Reference</a></li>
<li><a href="http://codex.wordpress.org/Function_Reference/fetch_feed">WP Codex Function Reference</a></li>
<li><a href="http://perishablepress.com/press/2009/04/26/import-and-display-rss-feeds-in-wordpress/">Import and Display RSS Feeds in WordPress</a></li>
</ul>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/11/import-and-display-feeds-in-wordpress/">Permalink</a> | <a href="http://digwp.com/2009/11/import-and-display-feeds-in-wordpress/#comments">14 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2009/11/import-and-display-feeds-in-wordpress/&title=How to Import and Display Feeds in WordPress 2.8 and&nbsp;Beyond">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/theme/" title="View all posts in Theme" rel="category tag">Theme</a> | Tagged: <a href="http://digwp.com/tag/feeds/" rel="tag">feeds</a>, <a href="http://digwp.com/tag/php/" rel="tag">PHP</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/11/import-and-display-feeds-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>How to Disable Comment Feeds for Individual&#160;Posts</title>
		<link>http://digwp.com/2009/11/disable-comment-feeds-individual-posts/</link>
		<comments>http://digwp.com/2009/11/disable-comment-feeds-individual-posts/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 22:32:06 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[feeds]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[posts]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=936</guid>
		<description><![CDATA[By default, WordPress generates a RSS feed for the comments on every post. Many sites take advantage of this by offering the feed next to the comments area, enabling anyone to stay current with conversation. A typical feed menu for many blogs includes the following items:

Main Content Feed (posts, articles, etc.)
Main Comments Feed (all comments [...]]]></description>
			<content:encoded><![CDATA[<p>By default, WordPress generates a <acronym title="Really Simple Syndication">RSS</acronym> feed for the comments on every post. Many sites take advantage of this by offering the feed next to the comments area, enabling anyone to stay current with conversation. A typical feed menu for many blogs includes the following items:</p>
<ul>
<li>Main Content Feed (posts, articles, etc.)</li>
<li>Main Comments Feed (all comments left on your site)</li>
<li>Comments Feed for individual posts (all comments left on a post)</li>
</ul>
<p>This is a nice feed offering, but many people use the <a href="http://wordpress.org/extend/plugins/subscribe-to-comments/">Subscribe to Comments</a> plugin and find the individual-post feeds to be unnecessary. In this situation, it is easy enough to remove all comment-feed links from the theme-template files, but even after the physical links are removed, WordPress will continue to generate links in the <code>&lt;head&gt;</code> section of your pages.</p>
<p><span id="more-936"></span></p>
<p>This may not be a big deal, but visitors with a &ldquo;feed-aware&rdquo; browser such as Firefox, Opera, and Safari (I think) may be alerted to the availability of these feeds. Besides leading to potential confusion, you may not want people to actually subscribe to these feeds for whatever reason.</p>
<p>These individual comment-feed links are automatically created by the <code>wp_head</code> function when present in the <code>&lt;head&gt;</code> section of your <code>header.php</code> file. Fortunately, there are a couple of ways to eliminate these links from your pages. For the first technique, drop the following code into your active theme&rsquo;s <code>functions.php</code> file:</p>
<pre><code>// disable comment feeds for individual posts
function disablePostCommentsFeedLink($for_comments) {
	return;
}
add_filter('post_comments_feed_link','disablePostCommentsFeedLink');</code></pre>
<p>That will stop the individual comment-feed <strong>links</strong> from appearing in your <code>&lt;head&gt;</code> section, but the actual <strong>feeds</strong> will remain available to anyone who is savvy enough to find them. I am pretty sure there is a way to stop the feeds themselves from being generated, but I can&rsquo;t seem to remember it. Hopefully someone will remind me.&nbsp;;)</p>
<p>While the previous method removes only the <em>individual</em> comment-feed links, there is another technique that will remove <em>all</em> feed links except for the main posts feed and main comments feed: </p>
<pre><code>// kill all extra feed links in the head
remove_action('wp_head','feed_links_extra', 3);</code></pre>
<p>As you might have guessed, this tasty little code slice goes into your <code>functions.php</code> file. Once there, it will eliminate all extraneous feed links (post-comments feed, archive feeds, tag feeds, category feeds, etc.), leaving links only for your site&rsquo;s two main feeds. To kill those feed links as well, add this additional slice:</p>
<p><code>remove_action('wp_head','feed_links', 2);</code></p>
<p>When combined, these two <code>remove_action</code> directives are pretty much going to kill all feed links in your <code>&lt;head&gt;</code>. So use with caution!</p>
<p style="border:1px solid #ccc; background: #eee; line-height: 20px; padding: 5px 10px; margin-top: 10px;">Like the article? <a href="http://digwp.com/book"><strong>Get the book!</strong></a></p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/11/disable-comment-feeds-individual-posts/">Permalink</a> | <a href="http://digwp.com/2009/11/disable-comment-feeds-individual-posts/#comments">6 comments</a> | Add to
<a href="http://del.icio.us/post?url=http://digwp.com/2009/11/disable-comment-feeds-individual-posts/&title=How to Disable Comment Feeds for Individual&nbsp;Posts">Delicious</a><br />
Categorized: <a href="http://digwp.com/category/php/" title="View all posts in PHP" rel="category tag">PHP</a>,  <a href="http://digwp.com/category/theme/" title="View all posts in Theme" rel="category tag">Theme</a> | Tagged: <a href="http://digwp.com/tag/feeds/" rel="tag">feeds</a>, <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/posts/" rel="tag">posts</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/11/disable-comment-feeds-individual-posts/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
