<?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>Weblimner &#187; popular posts</title>
	<atom:link href="http://www.weblimner.com/tag/popular-posts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.weblimner.com</link>
	<description></description>
	<lastBuildDate>Sun, 15 Aug 2010 23:49:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Show Popular Posts Without a Plugin</title>
		<link>http://www.weblimner.com/tutorial/show-popular-posts-without-a-plugin/</link>
		<comments>http://www.weblimner.com/tutorial/show-popular-posts-without-a-plugin/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 02:52:43 +0000</pubDate>
		<dc:creator>Ali Sipahioglu</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[popular posts]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.weblimner.com/?p=189</guid>
		<description><![CDATA[This is probably the shortest way of showing the popular posts in your plugin and it is the same way I use on the sidebar of this blog. First of all open your functions.php file inside your theme folder. If it doesn&#8217;t exist, just create an empty file named functions.php in your current theme folder. [...]]]></description>
			<content:encoded><![CDATA[<p>This is probably the shortest way of showing the popular posts in your plugin and it is the same way I use on the sidebar of this blog.<br />
<span id="more-189"></span><br />
First of all open your functions.php file inside your theme folder.<br />
<em>If it doesn&#8217;t exist, just create an empty file named functions.php in your current theme folder.</em></p>
<pre class="php">function get_mostpopular(){
 global $wpdb;
 $popular_posts = $wpdb-&gt;get_results("SELECT id,post_title FROM {$wpdb-&gt;prefix}posts ORDER BY comment_count DESC LIMIT 0,5");
 foreach($popular_posts as $post) {
 if ($a%2){$turn='class="odd"';}else{$turn='';}
 print "&lt;li $turn&gt;&lt;a href='". get_permalink($post-&gt;id) ."'&gt;".$post-&gt;post_title."&lt;/a&gt;&lt;/li&gt;\n";
 $a++;
 }
}</pre>
<p>Copy this code between  tags. Currently this code shows 5 posts with the highest number of comments. If you want to show more just change the 3rd line where it says <em>comment_count DESC LIMIT 0,5</em> and replace 5 with the number you want.<br/><br/></p>
<p>Also I add a class &#8220;odd&#8221; to every other line to generate the different color on each line. Now save your functions.php and open up your sidebar.php.<br/><br/></p>
<p>And wherever you want to show the popular posts just call the function from there.<br />
<br/></p>
<pre class="php">&lt;ul&gt;&lt;?php get_mostpopular(); }?&gt;&lt;/ul&gt;</pre>
<p><br/><br/><br />
<strong>Extra:</strong></p>
<p>The current styles I use for this list is as follows;</p>
<pre class="css">#sidebar li{
	padding: 5px 15px;
	background-color:#f2f0f7;
	border-bottom:1px solid #fff;
}
#sidebar li.odd{background-color:#ebe8f1;}
</pre>
<p>You might want to change the &#8220;#sidebar&#8221; to the id or class of your own sidebar.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.weblimner.com/tutorial/show-popular-posts-without-a-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Object Caching 251/267 objects using disk

Served from: www.weblimner.com @ 2012-02-06 03:37:18 -->
