<?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; posts</title>
	<atom:link href="http://digwp.com/tag/posts/feed/" rel="self" type="application/rss+xml" />
	<link>http://digwp.com</link>
	<description>Take your WordPress skills to the next level.</description>
	<lastBuildDate>Fri, 18 May 2012 18:21:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Next/Previous Post Navigation Outside of the WordPress Loop</title>
		<link>http://digwp.com/2010/04/post-navigation-outside-loop/</link>
		<comments>http://digwp.com/2010/04/post-navigation-outside-loop/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 12:50:50 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[posts]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1975</guid>
		<description><![CDATA[WordPress provides several navigational template tags to make it easy for visitors to surf your pages. There are basically two different types of template tags used for chronological post navigation: posts_nav_link() &#8211; for navigating various archive (non-single) pages previous_post_link() &#38; next_post_link() &#8211; for navigating single-post pages These template tags output the HTML markup required to [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress provides several <a href="http://digwp.com/2009/08/wordpress-page-navigation/" title="Definitive Guide to WordPress Page Navigation">navigational template tags</a> to make it easy for visitors to surf your pages. There are basically two different types of template tags used for chronological post navigation:</p>
<ul>
<li><code>posts_nav_link()</code> &ndash; for navigating various archive (non-single) pages</li>
<li><code>previous_post_link()</code> &amp; <code>next_post_link()</code> &ndash; for navigating single-post pages</li>
</ul>
<p>These template tags output the <acronym title="Hypertext Markup Language">HTML</acronym> markup required to create the actual hyperlinks that will appear on your web pages. By default, navigation links for single pages display the title of adjacent posts, while those for archive pages display &ldquo;Next-Page&rdquo; and &ldquo;Previous-Page&rdquo;.</p>
<p>Of course, the default text, link-position, and just about everything else can be <a href="http://digwp.com/2009/12/optimizing-wordpress-post-navigation/" title="Optimizing WordPress Post Navigation">customized and optimized</a> according to your specific needs.</p>
<p><span id="more-1975"></span></p>
<p>Normally, WordPress&rsquo; navigational template tags appear within the loop:</p>
<div id="post_1975">
<pre><code>&lt;?php get_header(); ?&gt;

	&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;

		&lt;h1&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt;
		&lt;?php the_content(); ?&gt;

	&lt;?php endwhile; ?&gt;

		&lt;p class="nav"&gt;&lt;?php posts_nav_link(); ?&gt;&lt;/p&gt;

	&lt;?php else : ?&gt;

		&lt;h1&gt;Nothing Found&lt;/h1&gt;
		&lt;p&gt;Please try a little harder next time..&lt;/p&gt;

	&lt;?php endif; ?&gt;

&lt;?php get_footer(); ?&gt;</code></pre>
</div>
<p>This code is typical for <code>index.php</code> and other &ldquo;Archive-View&rdquo; pages, such as for Categories, Tags, Search Results, and so on. Similar code is used for Single Page-Views, where <code>single.php</code> would replace the <code>posts_nav_link()</code>&nbsp;<sup>1</sup> template tag for <code>previous_post_link()</code> and <code>next_post_link()</code> tags.</p>
<p>The navigational template tags are generally placed between the <code>endwhile</code> and <code>else</code>&nbsp;<sup>2</sup> statements, along with stuff like post comments, meta information, and social-media links. Within this section of the loop, code is processed only once, as opposed to multiple times in the first part of the loop.</p>
<h3>Navigation <em>outside</em> of the loop</h3>
<p>The good news is that the template tag for archive-view navigation (i.e., non-single pages) seems to work just fine outside of the loop. So you can just place <code>posts_nav_link()</code> anywhere within your theme template.</p>
<p>Then, to include <strong>single-view</strong> navigation outside of the loop, we can use <code>query_posts</code> to substantiate the loop anywhere within your <code>single.php</code> file. Here is a simplified version of the code that I am using at <a href="http://perishablepress.com/" title="Digital Design and Dialogue">Perishable Press</a>:</p>
<pre><code>&lt;?php $posts = query_posts($query_string); if (have_posts()) : while (have_posts()) : the_post(); ?&gt;

	&lt;?php previous_post_link(); ?&gt; | &lt;?php next_post_link(); ?&gt;

&lt;?php endwhile; endif; ?&gt;</code></pre>
<p>That&rsquo;s all there is to it, really. A nice trick to have in the hat. Then, we can take it a step further and consolidate both types of page navigation (single and archive) in a single chunk of code:</p>
<pre><code>&lt;?php if(is_single()) { // single-view navigation ?&gt;

	&lt;?php $posts = query_posts($query_string); if (have_posts()) : while (have_posts()) : the_post(); ?&gt;

		&lt;?php previous_post_link(); ?&gt; | &lt;?php next_post_link(); ?&gt;

	&lt;?php endwhile; endif; ?&gt;

&lt;?php } else { // archive view navigation ?&gt;

		&lt;?php posts_nav_link(); ?&gt;

&lt;?php } ?&gt;</code></pre>
<p>This code displays the appropriate template tags for both single-page-views and archive-views. If placed in its own file named &ldquo;<code>nav.php</code>&rdquo;, including it within your theme files is as simple as a template tag:</p>
<pre><code>&lt;?php include_once("nav.php"); ?&gt;</code></pre>
<p>That&rsquo;s an easy way to get your Next/Previous page navigation working anywhere outside the loop. This could easily be made into a <a href="http://digwp.com/2010/03/wordpress-functions-php-template-custom-functions/" title="WordPress functions.php Template with 15 Essential Custom Functions">custom function</a> for your theme&rsquo;s <a href="http://digwp.com/2010/04/wordpress-custom-functions-php-template-part-2/" title="WordPress Custom functions.php Template, Part 2">functions.php file</a>. Or maybe even <a href="http://digwp.com/2010/03/add-plugin-to-wordpress-plugin-repository/" title="How to Add Your Plugin to the WordPress Plugin Directory">a plugin</a>..?&nbsp;;)</p>
<p>For more information on WordPress Page Navigation, check out these fine <acronym title="Digging into WordPress">DiW</acronym> articles:</p>
<ul>
<li><a href="http://digwp.com/2009/08/wordpress-page-navigation/">Definitive Guide to WordPress Page Navigation</a></li>
<li><a href="http://digwp.com/2009/12/optimizing-wordpress-post-navigation/">Optimizing WordPress Post Navigation</a></li>
</ul>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/04/post-navigation-outside-loop/">Permalink</a> | <a href="http://digwp.com/2010/04/post-navigation-outside-loop/#comments">15 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/04/post-navigation-outside-loop/&title=Next/Previous Post Navigation Outside of the WordPress Loop">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/navigation/" rel="tag">navigation</a>, <a href="http://digwp.com/tag/posts/" rel="tag">posts</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/04/post-navigation-outside-loop/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>6 Ways to Display WordPress Post Content in Multiple Columns</title>
		<link>http://digwp.com/2010/03/wordpress-post-content-multiple-columns/</link>
		<comments>http://digwp.com/2010/03/wordpress-post-content-multiple-columns/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 08:25:45 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[posts]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1647</guid>
		<description><![CDATA[Most blogs display their content in single columns, but it&#8217;s also possible to display content in multiple columns. Multiple-column layouts are perfect for newspaper and magazine-style themes. Here are six ways of getting the job done. Using CSS3 and progressive enhancement Multiple columns by filtering the_content More flexible multiple columns Multiple loops displayed in multiple [...]]]></description>
			<content:encoded><![CDATA[<p>Most blogs display their content in single columns, but it&rsquo;s also possible to display content in <strong>multiple columns</strong>. Multiple-column layouts are perfect for newspaper and magazine-style themes. Here are six ways of getting the job done.</p>
<ol id="post-menu">
<li><a href="http://digwp.com/2010/03/wordpress-post-content-multiple-columns/#css3">Using CSS3 and progressive enhancement</a></li>
<li><a href="http://digwp.com/2010/03/wordpress-post-content-multiple-columns/#filter">Multiple columns by filtering the_content</a></li>
<li><a href="http://digwp.com/2010/03/wordpress-post-content-multiple-columns/#flexible">More flexible multiple columns</a></li>
<li><a href="http://digwp.com/2010/03/wordpress-post-content-multiple-columns/#loops">Multiple loops displayed in multiple columns</a></li>
<li><a href="http://digwp.com/2010/03/wordpress-post-content-multiple-columns/#horizontal">Display your posts in horizontal display order with two columns</a></li>
<li><a href="http://digwp.com/2010/03/wordpress-post-content-multiple-columns/#bonus">Bonus: Display your category list in two columns</a></li>
</ol>
<h3 id="css3">1. Using CSS3 and progressive enhancement</h3>
<p>I think the easiest way to display your content in multiple columns is to apply a little <acronym title="Cascading Style Sheets">CSS</acronym>3 in progressively enhancing fashion. Let&rsquo;s say you have the following markup:</p>
<pre><code>&lt;div class="content"&gt;
	&lt;p&gt;Lorem ipsum..&lt;/p&gt;
	&lt;p&gt;Lorem ipsum..&lt;/p&gt;
	&lt;p&gt;Lorem ipsum..&lt;/p&gt;
&lt;/div&gt;</code></pre>
<p><span id="more-1647"></span></p>
<p>We can add the following <acronym title="Cascading Style Sheets">CSS</acronym> to display the content in multiple columns:</p>
<pre><code>.content {
	  -moz-column-count: 3;
	  -moz-column-gap: 10px;
	  -moz-column-rule: none;
	  -webkit-column-count: 3;
	  -webkit-column-gap: 10px;
	  -webkit-column-rule: none;
	column-count: 3;
	column-gap: 10px;
	column-rule: none;
	}</code></pre>
<p>This will display your content in three columns with a <code>10px</code> gap between each. This technique is a great way to enhance the display of your content for people running cool modern browsers like Safari and Firefox. What about folks visiting with Internet Exploder or older browsers? They will see your content displayed in a single column, just like they would have before you applied the multiple columns. <strong>Note</strong> that you can specify any number of coulmns and any width for the gap.</p>
<h3 id="filter">2. Multiple columns by filtering the_content</h3>
<p>If you need something a little more &ldquo;universal&rdquo; than what is currently available with <acronym title="Cascading Style Sheets">CSS</acronym>3, we can always dig into our template files, modify things at the <acronym title="PHP: Hypertext Preprocessor">PHP</acronym>/<acronym title="(eXtensible) Hypertext Markup Language">(X)HTML</acronym> level, and then style accordingly. Here is the technique provided by <a href="http://www.kriesi.at/archives/wordpress-display-content-in-multiple-columns" title="Wordpress: Display Content in multiple Columns">Kriesi.at</a>:</p>
<pre><code>function my_multi_col($content) {

	$columns = explode('&lt;h2&gt;', $content);
	$i = 0;

	foreach ($columns as $column) {
		if (($i % 2) == 0) {
			$return .= '&lt;div class="content_left"&gt;'."\n";
			if ($i &gt; 1) {
				$return .= "&lt;h2&gt;";
			} else {
				$return .= '&lt;div class="content_right"&gt;'."\n &lt;h2&gt;";
			}
			$return .= $column;
			$return .= '&lt;/p&gt;&lt;/div&gt;';
			$i++;
		}
		if(isset($columns[1])) {
	    		$content = wpautop($return);
		} else {
	    		$content = wpautop($content);
		}
		echo $content;
	}
}
add_filter('the_content', 'my_multi_col');</code></pre>
<p>Just place that into your active theme&rsquo;s <code>functions.php</code> file and then apply the following <acronym title="Cascading Style Sheets">CSS</acronym>:</p>
<pre><code>.content_right, .content_left{
	float: left;
	width: 45%;
	}
.content_left{
	padding-right: 5%;
	}</code></pre>
<p>Once implemented, this multi-column technique creates a a column for each instance of <code>&lt;h2&gt;</code> found within the post content. Thus, be sure to limit the number of <code>&lt;h2&gt;</code> elements to two in order to avoid layout breakage. <strong>Note</strong> that you could also modify the code to use a different element if the <code>&lt;h2&gt;</code> tag isn&rsquo;t good for you. Multiple columns doesn&rsquo;t get much easier, but just in case you need an alternate method for whatever reason, read on for some more great techniques.</p>
<h3 id="flexible">3. More flexible multiple columns</h3>
<p>The previous method works nice for two columns and no fuss, but for three or more columns we&rsquo;re going to need something a little more robust. fortunately, <a href="http://www.robsearles.com/2009/07/05/wordpress-multiple-content-columns/" title="Wordpress: Multiple Content Columns">Rob Searles</a> shares a technique that allows any number of columns with completely different content in each. This technique creates columns based on multiple instances of the <code>&lt;!--</code><code>more--&gt;</code> tag. There are several caveats, so check the orginal article for all the details.</p>
<p>Here are the steps involved in implementing this technique:</p>
<ol>
<li>Add the <code>my_multi_col_v2</code> function to your <code>functions.php</code> file</li>
<li>Add another snippet to your theme template file, for example <code>page.php</code></li>
<li>Add some <acronym title="Cascading Style Sheets">CSS</acronym> to format the markup into columns</li>
<li>Add a couple of <code>&lt;!--</code><code>more--&gt;</code> tags in your post or page to create the three columns</li>
</ol>
<p><strong>1.</strong> Let&rsquo;s go through these steps, beginning with the main function that you should place into your theme&rsquo;s <code>functions.php</code> file:</p>
<pre><code>function my_multi_col_v2($content){
	// run through a couple of essential tasks to prepare the content
	$content = apply_filters('the_content', $content);
	$content = str_replace(']]&gt;', ']]&amp;gt;', $content);
 
	// the first "more" is converted to a span with ID
	$columns = preg_split('/(&lt;span id="more-\d+"&gt;&lt;\/span&gt;)|(&lt;!--more--&gt;)&lt;\/p&gt;/', $content);
	$col_count = count($columns);
 
	if($col_count &gt; 1) {
		for($i=0; $i&lt;$col_count; $i++) {
			// check to see if there is a final &lt;/p&gt;, if not add it
			if(!preg_match('/&lt;\/p&gt;\s?$/', $columns[$i]) )  {
				$columns[$i] .= '&lt;/p&gt;';
			}
			// check to see if there is an appending &lt;/p&gt;, if there is, remove
			$columns[$i] = preg_replace('/^\s?&lt;\/p&gt;/', '', $columns[$i]);
			// now add the div wrapper
			$columns[$i] = '&lt;div class="dynamic-col-'.($i+1).'"&gt;'.$columns[$i].'&lt;/div&gt;';
		}
		$content = join($columns, "\n").'&lt;div class="clear"&gt;&lt;/div&gt;';
	}
	else {
		// this page does not have dynamic columns
		$content = wpautop($content);
	}
	// remove any left over empty &lt;p&gt; tags
	$content = str_replace('&lt;p&gt;&lt;/p&gt;', '', $content);
	return $content;
}</code></pre>
<p><strong>2.</strong> Once that&rsquo;s in place, replace your <code>the_content()</code> tag with the following code:</p>
<pre><code>$content = get_the_content('',FALSE,''); // arguments remove 'more' text
echo my_multi_col_v2($content);</code></pre>
<p><strong>3.</strong> The last bit of code that we need to setup is the <acronym title="Cascading Style Sheets">CSS</acronym> to make it all sweet:</p>
<pre><code>/* dynamic columns */
div.dynamic-col-1 { float: left; width: 38%; padding-right: 2%;}
div.dynamic-col-2 { float: left; width: 38%;padding-right: 2%;}
div.dynamic-col-3 { float: left; width: 20%;}
div.clear { clear: both; }</code></pre>
<p><strong>4.</strong> And last but not least, remember to add the two <code>&lt;!--</code><code>more--&gt;</code> tags in your post/page content to create the three columns.</p>
<p>That&rsquo;s all there is to it. Pretty good stuff, but even so, there are even more alternatives available. next we&rsquo;ll look at a technique for displaying multiple loops in multiple columns.</p>
<h3 id="loops">4. Multiple loops displayed in multiple columns</h3>
<p>Not too long ago, I wrote a post at Perishable Press explaining <a href="http://perishablepress.com/press/2008/09/01/multiple-loops-and-multiple-columns-with-wordpress/" title="Multiple Loops and Multiple Columns with WordPress, (X)HTML and CSS">how to display multiple loops with multiple columns</a>. The final product will look display something like this:</p>
<ul>
<li>First column, first loop: display posts #1-5</li>
<li>Second column, second loop: display posts #6-10</li>
<li>Third column, third loop: display posts #11-15</li>
</ul>
<p>Using WordPress and a little <acronym title="Cascading Style Sheets">CSS</acronym>, this configuration is relatively easy to accomplish. Let&rsquo;s cut right to the chase..</p>
<h4>Step 1: Setup the multiple loops</h4>
<p>The first thing we want to do is replace the standard WordPress loop with the following code:</p>
<pre><code>// FIRST LOOP: display posts 1 thru 5
&lt;?php query_posts('showposts=5'); ?&gt;
&lt;?php $posts = get_posts('numberposts=5&amp;offset=0'); foreach ($posts as $post) : start_wp(); ?&gt;
&lt;?php static $count1 = 0; if ($count1 == "5") { break; } else { ?&gt;

&lt;?php the_title(); ?&gt;
&lt;?php the_content(); ?&gt;

&lt;?php $count1++; } ?&gt;
&lt;?php endforeach; ?&gt;


// SECOND LOOP: display posts 6 thru 10
&lt;?php query_posts('showposts=5'); ?&gt;
&lt;?php $posts = get_posts('numberposts=5&amp;offset=5'); foreach ($posts as $post) : start_wp(); ?&gt;
&lt;?php static $count2 = 0; if ($count2 == "5") { break; } else { ?&gt;

&lt;?php the_title(); ?&gt;
&lt;?php the_content(); ?&gt;

&lt;?php $count2++; } ?&gt;
&lt;?php endforeach; ?&gt;


// THIRD LOOP: display posts 11 thru 15
&lt;?php query_posts('showposts=5'); ?&gt;
&lt;?php $posts = get_posts('numberposts=5&amp;offset=10'); foreach ($posts as $post) : start_wp(); ?&gt;
&lt;?php static $count3 = 0; if ($count3 == "5") { break; } else { ?&gt;

&lt;?php the_title(); ?&gt;
&lt;?php the_content(); ?&gt;

&lt;?php $count3++; } ?&gt;
&lt;?php endforeach; ?&gt;</code></pre>
<p>That&rsquo;s the juice right there. We have three loops, each displaying five posts. The first loop displays the first five posts, the second loop displays the next five posts, and the third loop displays the next five posts. Thus, this multiple-loop configuration displays the most recent 15 posts, each of which being unique. <a href="http://perishablepress.com/press/2008/09/01/multiple-loops-and-multiple-columns-with-wordpress/" title="Multiple Loops and Multiple Columns with WordPress, (X)HTML and CSS">See the original post</a> for more information, options and details.</p>
<h4>Step 2: Markup your theme template file(s)</h4>
<p>Now that we have the <acronym title="PHP: Hypertext Preprocessor">PHP</acronym> in place, we are ready to add the <acronym title="(eXtensible) Hypertext Markup Language">(X)HTML</acronym> markup required for the final three-column configuration. There are many ways to accomplish this, this is merely one of them:</p>
<pre><code>&lt;div id="column_01"&gt;

	&lt;!-- FIRST LOOP --&gt;

&lt;/div&gt;

&lt;div id="column_wrap"&gt;

	&lt;div id="column_02"&gt;

		&lt;!-- SECOND LOOP --&gt;

	&lt;/div&gt;
	&lt;div id="column_03"&gt;

		&lt;!-- THIRD LOOP --&gt;
	
	&lt;/div&gt;

&lt;/div&gt;</code></pre>
<p>Here, each of the three loops will be placed into its own <code>div</code>, which then will be styled with a little <acronym title="Cascading Style Sheets">CSS</acronym> to transform it into one of the three columns. Note that you may want to change the <code>id</code> names of the divisions to better represent the particular semantics of your document. Now let&rsquo;s move on to the <acronym title="Cascading Style Sheets">CSS</acronym>..</p>
<h4>Step 3: Styling the columns with CSS</h4>
<p>The final step in the tutorial is to style the markup with <acronym title="Cascading Style Sheets">CSS</acronym>. Nothing too fancy, really. Creating the columns is merely a matter of floating the individual divs and applying a width to each of them:</p>
<pre><code>/* three column layout */
div#column_01 {
	float: left;
	clear: none;
	width: 30%;
	}
div#column_wrap {
	float: right;
	clear: none;
	width: 60%;
	}
	div#column_02 {
		float: left;
		clear: none;
		width: 45%;
		}
	div#column_03 {
		float: right;
		clear: none;
		width: 45%;
		}</code></pre>
<p>The trick here is to use <code>width</code> values that will create the correct column widths. The values used in the example produce three columns of <em>approximately</em> equal width. Again, for more information on the details of this technique, see the original post.</p>
<p>Once you get everything setup, your posts should display your multiple-loop content in multiple columns, with each column showing the contents of a different loop. This is a great way to customize your theme, making it possible to present lots of disparate information within an easy-to-understand layout. Even so, this technique may not do it for you either. If so, we&rsquo;ve got a couple more WordPress tricks up our sleeve!</p>
<h3 id="horizontal">5. Display your posts in horizontal display order with two columns</h3>
<p>That&rsquo;s a mouthful, isn&rsquo;t it? What we&rsquo;re doing in this section is changing the order in which your two-column posts appear on the page. Typically, your two-column layout displays posts like this:</p>
<pre><code>Post #1   |   Post #4
Post #2   |   Post #5
Post #3   |   Post #6
 .        |    .
 .        |    .
 .        |    .</code></pre>
<p>All of the multi-column methods we&rsquo;ve discussed so far result in this sort of post-display order. So now we want to change things up a bit and display our two-column posts in <em>horizontal</em> display order, like so:</p>
<pre><code>Post #1   |   Post #2
Post #3   |   Post #4
Post #5   |   Post #6
 .        |    .
 .        |    .
 .        |    .</code></pre>
<p>How is this accomplished? As explained in my <a href="http://perishablepress.com/press/2008/08/04/two-column-horizontal-sequence-wordpress-post-order/" title="Horizontally Sequenced Display Order for WordPress Posts in Two Columns">horizontal-display tutorial</a>, this is easily accomplished using two default loops and the <code>rewind_posts()</code> function. The first loop will display the posts in the first column, while the second loop will display the posts in the second column. To do this, we use <acronym title="PHP: Hypertext Preprocessor">PHP</acronym>&rsquo;s <a  href="http://us.php.net/operators.arithmetic" title="PHP: Arithmetic Operators - Manual">modulus operator</a> to filter out every other post from the first loop, which will display posts in horizontal order.</p>
<p>To make this happen, first replace your default WordPress loop with the following code:</p>
<pre><code>&lt;?php if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) == 0) : $wp_query-&gt;next_post(); else : the_post(); ?&gt;

&lt;div id="left-column"&gt;
&lt;h1&gt;&lt;?php the_permalink(); ?&gt;&lt;/h1&gt;
&lt;?php the_content(); ?&gt;
&lt;/div&gt;

&lt;?php endif; endwhile; else: ?&gt;
&lt;div&gt;Alternate content&lt;/div&gt;
&lt;?php endif; ?&gt;

&lt;?php $i = 0; rewind_posts(); ?&gt;

&lt;?php if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) !== 0) : $wp_query-&gt;next_post(); else : the_post(); ?&gt;

&lt;div id="right-column"&gt;
&lt;h1&gt;&lt;?php the_permalink(); ?&gt;&lt;/h1&gt;
&lt;?php the_content(); ?&gt;
&lt;/div&gt;

&lt;?php endif; endwhile; else: ?&gt;
&lt;div&gt;Alternate content&lt;/div&gt;
&lt;?php endif; ?&gt;</code></pre>
<p>With that code in place, oddly numbered posts will appear within a division identified with an attribute of <code>id="left-column"</code>. Likewise, even-numbered posts will appear within a division identified with an attribute of <code>id="right-column"</code>. Thus, we may apply the following <acronym title="Cascading Style Sheets">CSS</acronym> to position the divisions as two adjacent columns:</p>
<pre><code>div#left-column {
	width: 333px;
	float: left;
	clear: none;
	}
div#right-column {
	width: 333px;
	float: right;
	clear: none;
	}</code></pre>
<p>Of course, when it comes to configuring the WordPress loop and styling your page with <acronym title="Cascading Style Sheets">CSS</acronym>,<br />
anything is possible. Feel free to experiment and adapt this technique to suit your own diabolical purposes&nbsp;;) As with the other methods described in this <acronym title="Digging into WordPress">DiW</acronym> post, much more information is available for this technique at the <a href="http://perishablepress.com/press/2008/08/04/two-column-horizontal-sequence-wordpress-post-order/" title="Horizontally Sequenced Display Order for WordPress Posts in Two Columns">original article</a>, including a nice, <acronym title="Cascading Style Sheets">CSS</acronym>-only method that is sure to leave you breathless.</p>
<h3 id="bonus">6. Bonus: Display your category list in two columns</h3>
<p>Using a little <acronym title="PHP: Hypertext Preprocessor">PHP</acronym> magic, we can get WordPress&rsquo; <code>wp_list_categories()</code> to display our <strong>categories in two columns</strong>. As <a href="http://www.blogohblog.com/10-wordpress-hacks-to-make-your-life-even-easier/" title="10 WordPress Hacks to Make Your Life Even Easier">Blog Oh Blog</a> explains, all you need is the following code placed in your theme file:</p>
<pre><code>&lt;?php // display categories in two columns
$cats = explode('&lt;br /&gt;', wp_list_categories('title_li=&amp;echo=0&amp;depth=1&amp;style=none'));
$cat_n = count($cats) - 1;
for ($i = 0; $i &lt; $cat_n; $i++):
	if ($i &lt; $cat_n/2):
		$cat_left = $cat_left.'&lt;li&gt;'.$cats[$i].'&lt;/li&gt;';
	elseif ($i &gt;= $cat_n/2):
		$cat_right = $cat_right.'&lt;li&gt;'.$cats[$i].'&lt;/li&gt;';
	endif;
endfor; ?&gt;

&lt;ul class="left"&gt;
	&lt;?php echo $cat_left; ?&gt;
&lt;/ul&gt;
&lt;ul class="right"&gt;
	&lt;?php echo $cat_right; ?&gt;
&lt;/ul&gt;</code></pre>
<p>Just use that code where you would like the categories to appear and enjoy the results.</p>
<h3>Wrapping it up</h3>
<p>Hopefully these techniques will inspire and enable you to break out of the &ldquo;single-column&rdquo; mindset and explore some multi-column possibilities. Using multiple columns for your content is a great way to enhance the visual appeal of your design and readability of your content.</p>
<p>There is SO much you can do with WordPress, <acronym title="PHP: Hypertext Preprocessor">PHP</acronym>, <acronym title="(eXtensible) Hypertext Markup Language">(X)HTML</acronym>, and <acronym title="Cascading Style Sheets">CSS</acronym>. The possibilities are endless indeed. The multiple-column techniques presented in this article provide a great starting point for creating more elaborate and sophisticated page layouts. So experiment, have fun, and be safe!!</p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/03/wordpress-post-content-multiple-columns/">Permalink</a> | <a href="http://digwp.com/2010/03/wordpress-post-content-multiple-columns/#comments">30 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/03/wordpress-post-content-multiple-columns/&title=6 Ways to Display WordPress Post Content in Multiple Columns">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/css/" rel="tag">CSS</a>, <a href="http://digwp.com/tag/loop/" rel="tag">loop</a>, <a href="http://digwp.com/tag/php/" rel="tag">PHP</a>, <a href="http://digwp.com/tag/posts/" rel="tag">posts</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/03/wordpress-post-content-multiple-columns/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>WordPress Tip: Remove nofollow Attributes from Post Content</title>
		<link>http://digwp.com/2010/02/remove-nofollow-attributes-from-post-content/</link>
		<comments>http://digwp.com/2010/02/remove-nofollow-attributes-from-post-content/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 07:17:59 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[nofollow]]></category>
		<category><![CDATA[posts]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1352</guid>
		<description><![CDATA[If you have posts that include the nofollow attribute on links, you may at some point decide to remove them. By default, WordPress doesn&#8217;t insert nofollow attributes in post content, but there are a variety of plugins that will insert nofollow into all links in post content. Or perhaps you have been manually adding nofollow [...]]]></description>
			<content:encoded><![CDATA[<p>If you have posts that include the <code>nofollow</code> attribute on links, you may at some point decide to remove them. By default, WordPress doesn&rsquo;t insert <code>nofollow</code> attributes in post content, but there are a variety of plugins that will insert <code>nofollow</code> into all links in post content. Or perhaps you have been manually adding <code>nofollow</code> tags to your post links for <acronym title="Search Engine Optimization">SEO</acronym> purposes. Regardless of how they got there, it&rsquo;s very easy to clean things up and remove all <code>nofollow</code> attributes from post content.</p>
<p><span id="more-1352"></span></p>
<h3>Remove <code>nofollow</code> attributes from post content</h3>
<p>To clean up your post content, simply add the following code to your active theme&rsquo;s <code>functions.php</code> file:</p>
<pre><code>function remove_nofollow($string) {
	$string = str_ireplace(' rel="nofollow"', '', $string);
	return $string;
}
add_filter('the_content', 'remove_nofollow');</code></pre>
<p>That&rsquo;s all there is to it &#8212; no further editing required. Once in place, this function will filter all post content and remove any instances of <code>rel="nofollow"</code>. Note that if you have <a href="http://perishablepress.com/press/2007/09/23/much-ado-about-nofollow-the-perishable-press-dofollow-series/" title="Much ado about nofollow: The Perishable Press Dofollow Series">some posts about nofollow</a>, this function will remove <code>rel="nofollow"</code> from your code examples as well.</p>
<h3>Remove <code>nofollow</code> attributes from post content and comment text</h3>
<p>It&rsquo;s just as easy to remove <code>nofollow</code> tags from comment text by including another <code>add_filter</code> function:</p>
<pre><code>function remove_nofollow($string) {
	$string = str_ireplace(' rel="nofollow"', '', $string);
	return $string;
}
add_filter('the_content', 'remove_nofollow');
add_filter('comment_text', 'remove_nofollow');</code></pre>
<p>With the additional <code>add_filter</code>, this code will eliminate all instances of <code>rel="nofollow"</code> that would have otherwise appeared in your post content and comment text.</p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/02/remove-nofollow-attributes-from-post-content/">Permalink</a> | <a href="http://digwp.com/2010/02/remove-nofollow-attributes-from-post-content/#comments">18 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/02/remove-nofollow-attributes-from-post-content/&title=WordPress Tip: Remove nofollow Attributes from Post Content">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/functions/" rel="tag">functions</a>, <a href="http://digwp.com/tag/nofollow/" rel="tag">nofollow</a>, <a href="http://digwp.com/tag/posts/" rel="tag">posts</a>, <a href="http://digwp.com/tag/tips/" rel="tag">tips</a>, <a href="http://digwp.com/tag/tricks/" rel="tag">tricks</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/02/remove-nofollow-attributes-from-post-content/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Optimizing WordPress Post Navigation</title>
		<link>http://digwp.com/2009/12/optimizing-wordpress-post-navigation/</link>
		<comments>http://digwp.com/2009/12/optimizing-wordpress-post-navigation/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 06:20:55 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[posts]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=1058</guid>
		<description><![CDATA[Implementing a solid set of navigational links for your WordPress site is one of the best ways to encourage visitors to stick around awhile and check out additional content. As discussed in our definitive guide to WordPress post navigation, there are essentially three different types of navigational tags for WordPress: Index and archive navigation: posts_nav_link() [...]]]></description>
			<content:encoded><![CDATA[<p>Implementing a solid set of navigational links for your WordPress site is one of the best ways to encourage visitors to stick around awhile and check out additional content. As discussed in our <a href="http://digwp.com/2009/08/wordpress-page-navigation/" title="Definitive Guide to WordPress Page Navigation">definitive guide to WordPress post navigation</a>, there are essentially three different types of navigational tags for WordPress:</p>
<ul>
<li>Index and archive navigation: <a href="http://digwp.com/2009/08/wordpress-page-navigation/#postsnavlink" title="posts_nav_link()">posts_nav_link()</a></li>
<li>Index and archive navigation: <a href="http://digwp.com/2009/08/wordpress-page-navigation/#previouspostslink" title="previous_posts_link() and next_posts_link()">previous_posts_link() and next_posts_link()</a></li>
<li>Single-view posts navigation: <a href="http://digwp.com/2009/08/wordpress-page-navigation/#previouspostlink" title="previous_post_link() and next_post_link()">previous_post_link() and next_post_link()</a></li>
</ul>
<p>Without repeating ourselves, suffice it to say that <code>previous_posts_link</code> and <code>next_posts_link</code> are perfect for setting up separate links for index, category, and archive pages. Likewise, <code>previous_post_link</code> and <code>next_post_link</code> are perfect for setting up separate links for single-view post navigation.</p>
<p>Now that we&rsquo;re on the same page, so to speak, let&rsquo;s look at how these tags are typically used and how to improve and optimize their functionality..</p>
<p><span id="more-1058"></span></p>
<h3>Improving the <code>next_posts_link</code> and <code>previous_posts_link</code> (for archive views)</h3>
<p>Here are the archive/category navigation links as provided in the default theme that is packaged with WordPress:</p>
<pre><code>&lt;div class="navigation"&gt;
	&lt;div class="alignleft"&gt;&lt;?php next_posts_link('&amp;laquo; Older Entries') ?&gt;&lt;/div&gt;
	&lt;div class="alignright"&gt;&lt;?php previous_posts_link('Newer Entries &amp;raquo;') ?&gt;&lt;/div&gt;
&lt;/div&gt;</code></pre>
<p>Functionally, this setup works great &#8212; the previous-post link is displayed <em>only</em> when there are previous posts, and likewise the next-post link is displayed <em>only</em> when there are newer posts. As convenient as this is, it doesn&rsquo;t help us with the accompanying markup used to display the links. Any <acronym title="Cascading Style Sheets">CSS</acronym> styles applied to the <code>&lt;div&gt;</code>s in our example will be displayed even when the links themselves aren&rsquo;t displayed. This can result in several issues, including:</p>
<ul>
<li>Padding and margins may prevent proper display when links are missing</li>
<li>Background images used to enhance the navigational links will still be displayed</li>
<li>Additional text and/or characters will still be displayed even when links absent</li>
<li>Use of any markup other than <code>&lt;div&gt;</code>s may result in validation errors when left empty</li>
</ul>
<p>And we&rsquo;re not just talking about the front page and last page here &#8212;  any category, tag, search, date, or author archive will also display botched navigational elements and design flaws when previous and next posts are unavailable. Your main index may always have previous posts, but what about that guest author archive, 2005 archive, and search results? Such pages are frequently one of a kind. Even worse, by defualt, your Home page will <em>never</em> have a page after it, which means a broken navigational element right there on the most important page of your site. Not good.</p>
<p>The easiest way that I have found to prevent this from happening when the &ldquo;next&rdquo; link is not generated is to simply test the <code>$paged</code> variable for a value greater than <code>1</code>:</p>
<pre><code>&lt;?php if ($paged &gt; 1) { ?&gt;

	&lt;div class="navigation"&gt;
		&lt;div class="alignleft"&gt;&lt;?php next_posts_link('&amp;laquo; Older Entries') ?&gt;&lt;/div&gt;
		&lt;div class="alignright"&gt;&lt;?php previous_posts_link('Newer Entries &amp;raquo;') ?&gt;&lt;/div&gt;
	&lt;/div&gt;

&lt;?php } ?&gt;</code></pre>
<p>By checking if there are more posts to display before calling the navigational code, this technique will prevent empty elements from wrinkling your home page and archive pages. Another way of doing this is shared by <a href="http://www.ericmmartin.com/conditional-pagepost-navigation-links-in-wordpress-redux/" title="Conditional page/post navigation links in WordPress (redux)">Eric Martin</a>. Just place this snippet into your active theme&rsquo;s <code>functions.php</code> file:</p>
<pre><code>// return TRUE if more than one page exists
function show_posts_nav() {
	global $wp_query;
	return ($wp_query-&gt;max_num_pages &gt; 1);
}</code></pre>
<p>And then use the function to conditionally display navigational code in your <code>archive.php</code> and other archive-view template files:</p>
<pre><code>&lt;?php if (show_posts_nav()) : ?&gt;

	&lt;div class="navigation"&gt;
		&lt;div class="alignleft"&gt;&lt;?php next_posts_link('&amp;laquo; Older Entries') ?&gt;&lt;/div&gt;
		&lt;div class="alignright"&gt;&lt;?php previous_posts_link('Newer Entries &amp;raquo;') ?&gt;&lt;/div&gt;
	&lt;/div&gt;

&lt;?php endif; ?&gt;</code></pre>
<p>Not sure if there is any benefit to adding the extra code in the <code>functions.php</code> file, but I thought I would share that technique with you as another possible solution (hey you never know).</p>
<p>Also, a great way to improve the functionality and presentation of your blog is to provide some alternate navigational elements to help keep things flowing and balanced on the front pages of your site. For example, at <a href="http://perishablepress.com/" title="Digital Design and Dialogue">Perishable Press</a>, if the &ldquo;next&rdquo; link isn&rsquo;t displayed, I provide a link to my site Archives:</p>
<pre><code>&lt;?php if ($paged &gt; 1) { ?&gt;

	&lt;div class="navigation"&gt;
		&lt;div class="alignleft"&gt;&lt;?php next_posts_link('&amp;laquo; Older Entries') ?&gt;&lt;/div&gt;
		&lt;div class="alignright"&gt;&lt;?php previous_posts_link('Newer Entries &amp;raquo;') ?&gt;&lt;/div&gt;
	&lt;/div&gt;

&lt;?php } else { ?&gt;

	&lt;div class="navigation"&gt;
		&lt;div class="alignleft"&gt;&lt;?php next_posts_link('&amp;laquo; Older Entries') ?&gt;&lt;/div&gt;
		&lt;div class="alignright"&gt;&lt;a href="http://perishablepress.com/press/archives/"&gt;Site Archives &amp;raquo;&lt;/a&gt;&lt;/div&gt;
	&lt;/div&gt;

&lt;?php } ?&gt;</code></pre>
<p>And of course, anything is possible here; the key is to keep things consistent, logical, and well-styled. Now let&rsquo;s see how to improve navigational display for single-post views.</p>
<h3>Improving the <code>next_post_link</code> and <code>previous_post_link</code> (for single views)</h3>
<p>Fortunately, the situation is much improved for single-post navigation. By default, the <code>next_post_link</code> and <code>previous_post_link</code> provide parameters that enable us to avoid the &ldquo;empty-element&rdquo; syndrome. Let&rsquo;s take a look at these parameters:</p>
<p><code>&lt;?php next_post_link('format','link','in_same_cat','excluded_categories'); ?&gt;</code><br />
<code>&lt;?php previous_post_link('format','link','in_same_cat','excluded_categories'); ?&gt;</code></p>
<p>The <code>format</code> and <code>link</code> parameters enable us to do something like this:</p>
<pre><code>&lt;div class="navigation"&gt;

	&lt;?php previous_post_link('&lt;div class="alignleft"&gt;Previous entry: %link&lt;/div&gt;', '%title'); ?&gt;
	&lt;?php next_post_link('&lt;div class="alignright"&gt;Next entry: %link&lt;/div&gt;', '%title'); ?&gt;

&lt;/div&gt;</code></pre>
<p>Here we have replicated the markup in our previous examples, but have done so conditionally, such that the markup will only be displayed when the corresponding link is displayed, thereby enabling us to avoid empty elements when either the previous or next post-link is not displayed. As you can see, the single-post nav tags enable us to include the surrounding <acronym title="(eXtensible) Hypertext Markup Language">(X)HTML</acronym> and text <em>within</em> the function itself. We can do similar tricks with the actual link title. Check out our <a href="http://digwp.com/2009/08/wordpress-page-navigation/" title="Definitive Guide to WordPress Page Navigation">definitive guide to post navigation</a> for more information.</p>
<h3>Conditional navigational display for single posts</h3>
<p>Just as we did with the archive nav tags (<code>next_posts_link</code> and <code>previous_posts_link</code>), we can implement some conditional functionality to display alternate navigational links when viewing the first and last posts in any archive view. For example, if I also wanted to provide a link to my Site Archives when the &ldquo;next&rdquo; and/or &ldquo;previous&rdquo; links were <strong>not</strong> displayed, I could do so using the following code:</p>
<pre><code>&lt;div class="navigation"&gt;

	&lt;?php previous_post_link('&lt;div class="alignleft"&gt;Previous entry: %link&lt;/div&gt;', '%title'); ?&gt;
	&lt;?php if(!get_adjacent_post(false, '', true)) { 
		echo '&lt;div class="alignleft"&gt;&lt;a href="http://perishablepress.com/press/archives/"&gt;Site Archives&lt;/a&gt;&lt;/div&gt;'; 
	} ?&gt;

	&lt;?php next_post_link('&lt;div class="alignright"&gt;Next entry: %link&lt;/div&gt;', '%title'); ?&gt;
	&lt;?php if(!get_adjacent_post(false, '', false)) { 
		echo '&lt;div class="alignright"&gt;&lt;a href="http://perishablepress.com/press/archives/"&gt;Site Archives&lt;/a&gt;&lt;/div&gt;'; 
	} ?&gt;

&lt;/div&gt;</code></pre>
<p>Here we are using the <code>get_adjacent_post</code> function to determine whether or not there is a post before/after the current post. This enables us to conditionally display some sort of fallback navigation in the first- and last-post case. The <code>get_adjacent_post</code> tag accepts the following parameters:</p>
<ul>
<li><code>$in_same_cat</code> &ndash; specifies whether or not the adjacent post should be in the same category</li>
<li><code>$excluded_categories</code> &ndash; a comma-delimited list of categories for which the adjacent post should not belong</li>
<li><code>$previous</code> &ndash; specifies whether the previous post should be displayed</li>
</ul>
<p>That does it for the single-post views. Let&rsquo;s wrap things up with a way to consolidate and streamline the single and archive navigational methods..</p>
<h3>Optimize your theme&rsquo;s navigational code</h3>
<p>Finally, here is a nice way to clean up your theme files and source code. The first step is to streamline production by <a href="http://digwp.com/2009/07/getting-more-fine-grained-with-includes/" title="Getting More Fine-Grained with Includes">getting more fine-grained with includes</a>. This basically means that you can clean things up and save time/effort by moving your navigational code to its own file, named something like &ldquo;<code>navigation.php</code>&rdquo; or similar. You would then remove your nav code from your other template files and consolidate them all into that one location. You would then include <code>navigation.php</code> in any theme file where you want the navigation section to appear:</p>
<pre><code>&lt;?php include_once("navigation.php"); ?&gt;</code></pre>
<p>This technique makes maintaining and modifying your code a breeze. And, you can even streamline things further by using some conditional logic to display either <em>archive</em> or <em>single</em> navigation depending on the current page being viewed:</p>
<pre><code>&lt;?php if (is_single()) : ?&gt;

	&lt;div class="navigation"&gt;
		&lt;?php previous_post_link('&lt;div class="alignleft"&gt;Previous entry: %link&lt;/div&gt;', '%title'); ?&gt;
		&lt;?php next_post_link('&lt;div class="alignright"&gt;Next entry: %link&lt;/div&gt;', '%title'); ?&gt;
	&lt;/div&gt;

&lt;?php else : ?&gt;

	&lt;div class="navigation"&gt;
		&lt;div class="alignleft"&gt;&lt;?php next_posts_link('&amp;laquo; Older Entries') ?&gt;&lt;/div&gt;
		&lt;div class="alignright"&gt;&lt;?php previous_posts_link('Newer Entries &amp;raquo;') ?&gt;&lt;/div&gt;
	&lt;/div&gt;

&lt;?php endif; ?&gt;</code></pre>
<p>This is a great way of staying organized and reducing your workload during theme development and maintenance.</p>
<h3>Wrap up</h3>
<p>The tips and tricks in this article will help you create a consistent, logical, and design-friendly set of navigational links for your next theme design. In the process, you can also streamline production by consolidating your code into a single file and using conditional logic to deliver the appropriate code.</p>
<hr />
<p><small>© 2009 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2009/12/optimizing-wordpress-post-navigation/">Permalink</a> | <a href="http://digwp.com/2009/12/optimizing-wordpress-post-navigation/#comments">10 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2009/12/optimizing-wordpress-post-navigation/&title=Optimizing WordPress Post Navigation">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/navigation/" rel="tag">navigation</a>, <a href="http://digwp.com/tag/optimization/" rel="tag">optimization</a>, <a href="http://digwp.com/tag/posts/" rel="tag">posts</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2009/12/optimizing-wordpress-post-navigation/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>How to Disable Comment Feeds for Individual 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 [...]]]></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>
<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 Posts">del.icio.us</a> | Post tags: <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><br/></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>

