<?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>Kilian Valkhof &#187; Wordpress</title>
	<atom:link href="http://kilianvalkhof.com/category/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://kilianvalkhof.com</link>
	<description></description>
	<lastBuildDate>Thu, 23 Feb 2012 14:41:38 +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>Popular posts for WordPress 2.6</title>
		<link>http://kilianvalkhof.com/2008/wordpress/popular-posts-for-wordpress-26/</link>
		<comments>http://kilianvalkhof.com/2008/wordpress/popular-posts-for-wordpress-26/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 01:00:27 +0000</pubDate>
		<dc:creator>Kilian Valkhof</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://kilianvalkhof.com/?p=130</guid>
		<description><![CDATA[<blockquote><p>I wanted something that wasn't so common, so I had to make something for myself.</p></blockquote><p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2008/wordpress/popular-posts-for-wordpress-26/">Popular posts for WordPress 2.6</a></p>
]]></description>
			<content:encoded><![CDATA[<p>On my homepage, I have the three most popular posts. Finding a plugin that did what I wanted <em>and</em> that worked with WordPress 2.6 proved to be quite impossible.<span id="more-130"></span></p>
<p>I wanted something that wasn&#8217;t so common: display the title, category, date, comments <em>and</em> excerpt, so I had to make something for myself.</p>
<h3>What it does</h3>
<p>At the moment, it&#8217;s quite basic. It sorts the posts on comment count, and displays the top <em>n</em> articles. I have three on my homepage. It uses the excellent <a href="http://rmarsh.com/plugins/">post plugin library</a> to get the date, category and excerpt into shape. (so, the post plugin library is needed for this to work). The code is based off of <a href="http://wordpress.org/support/topic/188045">this example</a> from the WordPress forums.</p>
<h3>The Code</h3>
<p>I haven&#8217;t looked into making wordpress plugins yet, so my popular post solution is just a snippet you can include in your theme:</p>
<pre><code>&lt;?php
	$sql='SELECT post_title, comment_count, guid, post_date, post_content, ID
	      FROM wp_posts
	      ORDER BY comment_count DESC
	      LIMIT 3;';
	$popresults = $wpdb-&gt;get_results($sql);

	foreach ($popresults as $r) {
		echo '&lt;div class="post"&gt;';
		echo '	&lt;h3&gt;&lt;a href="' . $r-&gt;guid . '"&gt;' . $r-&gt;post_title .'&lt;/a&gt;';
		echo '		&lt;span&gt;'. otf_categorylinks($r-&gt;ID, $r,', ').',';
		echo '			&lt;abbr title="'. oth_format_date($r-&gt;post_date, "j F Y") . '"&gt;'. oth_format_date($r-&gt;post_date, "j/m") . '&lt;/abbr&gt;,';
		echo '			&lt;abbr title="' . $r-&gt;comment_count . ' comments"&gt;' . $r-&gt;comment_count . '&lt;/abbr&gt;';
		echo '		&lt;/span&gt;';
		echo '	&lt;/h3&gt;';
		echo '	&lt;p&gt;'. oth_trim_excerpt($r-&gt;post_content, '45') .'…&lt;/p&gt;';
		echo '&lt;/div&gt;';
	}
?&gt;</code></pre>
<p>This snippet can be improved in a lot of ways. For one, making it a plugin would be a good idea. Secondly, attaching a time-based element would be nice, so that it can become &#8220;the popular posts of last month&#8221; instead of the all-time popular posts. Even more interesting would be linking it to the <a href="http://wordpress.org/extend/plugins/stats/">WP-Stats</a> plugin. That offers an &#8220;active posts&#8221; lists, which seems to be based off of comments and visits to a certain posts over a limited period of time.</p>
<p>This article is written by Kilian Valkhof, Front-end developer & User experience designer. Please visit <a href="http://kilianvalkhof.com">KilianValkhof.com</a> for more articles!<br/><br/><a href="http://kilianvalkhof.com/2008/wordpress/popular-posts-for-wordpress-26/">Popular posts for WordPress 2.6</a></p>
 <p><a href="http://kilianvalkhof.com/?flattrss_redirect&amp;id=130&amp;md5=85a02ee2dc5aab13c30529b0b07b55d3" title="Flattr" target="_blank"><img src="http://kilianvalkhof.com/wp-content/plugins/flattrss/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://kilianvalkhof.com/2008/wordpress/popular-posts-for-wordpress-26/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<atom:link rel="payment" href="https://flattr.com/submit/auto?user_id=28694&amp;popout=1&amp;url=http%3A%2F%2Fkilianvalkhof.com%2F2008%2Fwordpress%2Fpopular-posts-for-wordpress-26%2F&amp;language=en_GB&amp;category=text&amp;title=Popular+posts+for+WordPress+2.6&amp;description=On+my+homepage%2C+I+have+the+three+most+popular+posts.+Finding+a+plugin+that+did+what+I+wanted+and+that+worked+with+WordPress+2.6+proved+to+be+quite+impossible.+I...&amp;tags=blog" type="text/html" />
	</item>
	</channel>
</rss>

