CINXE.COM
How to List Your Most Popular Posts in WordPress | bavotasan.com
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml" dir="ltr" lang="en-US"> <head><script type="text/javascript" src="/_static/js/bundle-playback.js?v=HxkREWBo" charset="utf-8"></script> <script type="text/javascript" src="/_static/js/wombat.js?v=txqj7nKC" charset="utf-8"></script> <script>window.RufflePlayer=window.RufflePlayer||{};window.RufflePlayer.config={"autoplay":"on","unmuteOverlay":"hidden"};</script> <script type="text/javascript" src="/_static/js/ruffle/ruffle.js"></script> <script type="text/javascript"> __wm.init("https://web.archive.org/web"); __wm.wombat("http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/","20100918100854","https://web.archive.org/","web","/_static/", "1284804534"); </script> <link rel="stylesheet" type="text/css" href="/_static/css/banner-styles.css?v=S1zqJCYt" /> <link rel="stylesheet" type="text/css" href="/_static/css/iconochive.css?v=3PDvdIFv" /> <!-- End Wayback Rewrite JS Include --> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta name="googlebot" content="index,archive,follow,noodp"/> <meta name="robots" content="all,index,follow"/> <meta name="msnbot" content="all,index,follow"/> <meta name="description" content="I decided my sidebar was looking a little plain. It needed something more than just ads, so I placed a list of my popular posts there. I think it looks pre..."/> <meta name="keywords" content="Background Url,desc,Foreach,h2,Images,Padding,Php Function,Png,serif,Sidebar,WordPress,"/> <title>How to List Your Most Popular Posts in WordPress | bavotasan.com</title> <link rel="stylesheet" href="https://web.archive.org/web/20100918100854cs_/http://bavotasan.com/wp-content/themes/bavotasan-2010/style.css?ver=1.0.6" type="text/css" media="screen"/> <link rel="shortcut icon" href="https://web.archive.org/web/20100918100854im_/http://bavotasan.com/favicon.ico"/> <link rel="pingback" href="http://bavotasan.com/xmlrpc.php"/> <link rel="alternate" type="application/rss+xml" title="bavotasan.com 禄 Feed" href="https://web.archive.org/web/20100918100854/http://bavotasan.com/feed/"/> <link rel="alternate" type="application/rss+xml" title="bavotasan.com 禄 Comments Feed" href="https://web.archive.org/web/20100918100854/http://bavotasan.com/comments/feed/"/> <link rel="alternate" type="application/rss+xml" title="bavotasan.com 禄 How to List Your Most Popular Posts in WordPress Comments Feed" href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/feed/"/> <script type="text/javascript" src="https://web.archive.org/web/20100918100854js_/http://bavotasan.com/wp-includes/js/jquery/jquery.js?ver=1.4.2"></script> <link rel="index" title="bavotasan.com" href="http://bavotasan.com/"/> <link rel="start" title="Removing Images from a WordPress Post: Redux" href="http://bavotasan.com/tutorials/removing-images-from-a-wordpress-post/"/> <link rel="prev" title="Check if a Number is Even or Odd with PHP" href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/check-if-a-number-is-even-or-odd-with-php/"/> <link rel="next" title="Turn Text into an Image using the PHP GD Library" href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/turn-text-into-an-image-using-the-php-gd-library/"/> <link rel="canonical" href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/"/> <link rel="shortlink" href="https://web.archive.org/web/20100918100854/http://bit.ly/bsEieb"/> <script type="text/javascript" src="https://web.archive.org/web/20100918100854js_/http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js"></script> <meta property="fb:page_id" content="137456822940271"/> <meta property="fb:admins" content="586505548"/> <meta property="og:site_name" content="bavotasan.com"/> <meta property="og:title" content="How to List Your Most Popular Posts in WordPress"/> <meta property="og:description" content="I decided my sidebar was looking a little plain. It needed something more than just ads, so I placed a list of my popular posts there. I think it looks pretty cool and it was very simple to do. I just created a PHP function and added it to my functions.php files and then added [...]"/> <meta property="og:type" content="article"/> <meta property="og:image" content="https://web.archive.org/web/20100918100854im_/http://bavotasan.com/wp-content/uploads/2009/05/popularpost.jpg"/> </head> <body class="single single-post postid-576"> <div id="bodywrap"> <!-- BuySellAds.com Ad Code --> <script type="text/javascript"> (function(){ var bsa = document.createElement('script'); bsa.type = 'text/javascript'; bsa.async = true; bsa.src = '//web.archive.org/web/20100918100854/http://s3.buysellads.com/ac/bsa.js'; (document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(bsa); })(); </script> <!-- END BuySellAds.com Ad Code --> <!-- begin header --> <div id="header"> <div id="topmenu" class="menu-top-menu-container"><ul id="menu-top-menu" class="menu"><li id="menu-item-2254" class="menu-item menu-item-type-custom menu-item-2254"><a href="https://web.archive.org/web/20100918100854/http://themes.bavotasan.com/">Themes by bavotasan.com</a></li> <li id="menu-item-2255" class="menu-item menu-item-type-custom menu-item-2255"><a href="https://web.archive.org/web/20100918100854/http://support.bavotasan.com/">Support Forum</a></li> <li id="menu-item-2259" class="menu-item menu-item-type-custom menu-item-2259"><a href="https://web.archive.org/web/20100918100854/http://themes.bavotasan.com/affiliates">Affiliates</a></li> <li id="menu-item-2256" class="menu-item menu-item-type-post_type menu-item-2256"><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/about/">About</a></li> <li id="menu-item-2257" class="menu-item menu-item-type-post_type menu-item-2257"><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/services/">Services</a></li> <li id="menu-item-2258" class="menu-item menu-item-type-post_type menu-item-2258"><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/contact/">Contact</a></li> </ul></div> <div id="title"> <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/"> <img src="https://web.archive.org/web/20100918100854im_/http://bavotasan.com/images/bavotasan.png" alt="bavotasan.com" width="400" height="70"/> <span id="desc"></span></a> </div> <div id="follow"> <span></span> <a href="https://web.archive.org/web/20100918100854/http://twitter.com/bavotasan" class="twitter"></a> <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/feed/" class="rss"></a> </div> <div id="navigation" class="menu-main-menu-container"> <ul id="menu-main-menu" class="menu"> <li id="menu-item-2264"><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/"><span></span>Home</a></li> <li id="menu-item-2266"><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/category/articles/"><span></span>Articles</a></li> <li id="menu-item-2265" class="current-menu-item"><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/category/tutorials/"><span></span>Tutorials</a></li> <li id="menu-item-2267"><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/category/downloads/"><span></span>Downloads</a></li> </ul> </div> </div> <!-- end header --> <div id="mainwrapper"> <div id="leftcontent"> <div class="posttop"> <div class="thedate"><div class="month">May</div><div class="day">19</div><div class="year">2009</div></div> <h1>How to List Your Most Popular Posts in WordPress</h1> <br class="clear"/> <p>I decided my sidebar was looking a little plain. It needed something more than just ads, so I placed a list of my popular posts there. I think it looks pretty cool and it was very simple to do. I just created a PHP function and added it to my functions.php files and then added some styles to get it to look the way I wanted.<br/> <span id="more-576"></span><br/> First lets create the function. We’ll call it popularPosts. Be sure to add it between <?php and ?> tags.</p> <div class="wp_syntax"><table border="0" cellpadding="0" cellspacing="0"><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> popularPosts<span style="color: #009900;">(</span><span style="color: #000088;">$num</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span> <span style="color: #000088;">$posts</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-></span><span style="color: #004000;">get_results</span><span style="color: #009900;">(</span><span style="color: #0000ff;">"SELECT comment_count, ID, post_title FROM <span style="color: #006699; font-weight: bold;">$wpdb->posts</span> ORDER BY comment_count DESC LIMIT 0 , <span style="color: #006699; font-weight: bold;">$num</span>"</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">(</span><span style="color: #000088;">$posts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> setup_postdata<span style="color: #009900;">(</span><span style="color: #000088;">$post</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-></span><span style="color: #004000;">ID</span><span style="color: #339933;">;</span> <span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-></span><span style="color: #004000;">post_title</span><span style="color: #339933;">;</span> <span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-></span><span style="color: #004000;">comment_count</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">(</span><span style="color: #000088;">$count</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #000088;">$popular</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'<li>'</span><span style="color: #339933;">;</span> <span style="color: #000088;">$popular</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'<a href="'</span> <span style="color: #339933;">.</span> get_permalink<span style="color: #009900;">(</span><span style="color: #000088;">$id</span><span style="color: #009900;">)</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'" title="'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$title</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'">'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$title</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'</a> '</span><span style="color: #339933;">;</span> <span style="color: #000088;">$popular</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'</li>'</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #009900;">}</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$popular</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span></pre></div></td></tr></table></div> <p>Now to call the function, all we need to do is place this code wherever we want our list to appear. Let’s call for a list of 10 items by placing a ’10′ as our $num variable when we call our function.</p> <div class="wp_syntax"><table border="0" cellpadding="0" cellspacing="0"><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><div class="popular"> <h2>Most Popular Posts</h2> <ul> <span style="color: #000000; font-weight: bold;"><?php</span> <span style="color: #b1b100;">echo</span> popularPosts<span style="color: #009900;">(</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?></span> </ul> </div></pre></div></td></tr></table></div> <p>All that is left is some styles to make it look good. Here are the styles I used for my sidebar list.</p> <div class="wp_syntax"><table border="0" cellpadding="0" cellspacing="0"><tr><td><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.popular</span> <span style="color: #00AA00;">{</span> <span style="color: #000000; font-weight: bold;">clear</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">both</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">283px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">}</span> <span style="color: #6666ff;">.popular</span> ul<span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.popular</span> ul li <span style="color: #00AA00;">{</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">}</span> <span style="color: #6666ff;">.popular</span> ul li <span style="color: #00AA00;">{</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">4px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">(</span><span style="color: #ff0000; font-style: italic;">images/star.png</span><span style="color: #00AA00;">)</span> <span style="color: #993333;">no-repeat</span> <span style="color: #933;">2px</span> <span style="color: #933;">2px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">}</span> <span style="color: #6666ff;">.popular</span> h2 <span style="color: #00AA00;">{</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#aaa</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">22px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> Georgia<span style="color: #00AA00;">,</span><span style="color: #993333;">serif</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">15px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">}</span></pre></div></td></tr></table></div> <p>For the star, I used this image <img src="https://web.archive.org/web/20100918100854im_/http://bavotasan.com/wp-content/themes/bavotasan_new/images/star.png" alt="star"/> which I created in Illustartor.</p> <p>Just right click above or drag the image to your desktop and add it to the appropriate directory to complete the look. You can also replace that image with whatever you want to appear there.</p> <div class="buttonbox"> </div> </div> <div class="post"> <div class="socialleft">If you liked this, please share it.</div> <ul class="addtoany_list"> <li><a href="https://web.archive.org/web/20100918100854/http://twitter.com/share?url=http%3A%2F%2Fbit.ly%2FbsEieb&counturl=http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/" class="twitter-share-button" data-count="vertical" data-via="bavotasan">Tweet</a><script type="text/javascript" src="https://web.archive.org/web/20100918100854js_/http://platform.twitter.com/widgets.js"></script></li> <li><a href="https://web.archive.org/web/20100918100854/http://www.facebook.com/sharer.php?u=http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/&t=How to List Your Most Popular Posts in WordPress" title="Click to send this page to Facebook!" target="_blank" rel="nofollow" class="facebook-icon"></a></li> <li><a href="https://web.archive.org/web/20100918100854/http://digg.com/submit?phase=2&url=http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/&title=How to List Your Most Popular Posts in WordPress&bodytext=I decided my sidebar was looking a little plain. It needed something more than just ads, so I placed a list of my popular posts there. I think it looks pretty cool and it was very simple to do. I just created a PHP function and added it to my functions.php files and then added [...]" title="Digg" rel="nofollow" target="_blank" class="digg-icon"></a></li> <li><a href="https://web.archive.org/web/20100918100854/http://www.delicious.com/save" onclick="window.open('https://web.archive.org/web/20100918100854/http://www.delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent('https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/')+'&title='+encodeURIComponent('How to List Your Most Popular Posts in WordPress'),'delicious', 'toolbar=no,width=550,height=550'); return false;" class="delicious-icon"></a></li> <li><a href="https://web.archive.org/web/20100918100854/http://www.stumbleupon.com/submit?url=http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/&title=How to List Your Most Popular Posts in WordPress" title="StumbleUpon" rel="nofollow" target="_blank" class="stumbleupon-icon"></a></li> <li><iframe src="https://web.archive.org/web/20100918100854if_/http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fbavotasan.com%2Ftutorials%2Fhow-to-list-your-most-popular-posts-in-wordpress%2F&layout=button_count&show_faces=false&width=100&action=like&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowtransparency="true"></iframe></li> </ul> </div> <div class="post"> <p class="tags">Tags: <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tag/background-url/" rel="tag">Background Url</a>, <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tag/desc/" rel="tag">desc</a>, <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tag/foreach/" rel="tag">Foreach</a>, <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tag/h2/" rel="tag">h2</a>, <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tag/images/" rel="tag">Images</a>, <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tag/padding/" rel="tag">Padding</a>, <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tag/php-function/" rel="tag">Php Function</a>, <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tag/png/" rel="tag">Png</a>, <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tag/serif/" rel="tag">serif</a>, <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tag/sidebar/" rel="tag">Sidebar</a>, <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tag/wordpress/" rel="tag">WordPress</a></p> <p class="tags">Short URL: <a href="https://web.archive.org/web/20100918100854/http://bit.ly/bsEieb" title="How to List Your Most Popular Posts in WordPress">http://bit.ly/bsEieb</a></p> </div> <div class="post"> <div id="crp_related"> <h3>Similar Posts</h3> <ul> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/adding-tweet-button-wordpress/" rel="bookmark" title="Permanent Link to Adding a Tweet Button to WordPress">Adding a Tweet Button to WordPress</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/developing-themes-for-wordpress-options/" rel="bookmark" title="Permanent Link to Developing Themes for WordPress: Part 4">Developing Themes for WordPress: Part 4</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/developing-themes-for-wordpress-template-file/" rel="bookmark" title="Permanent Link to Developing Themes for WordPress: Part 2">Developing Themes for WordPress: Part 2</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/developing-themes-for-wordpress-part-1/" rel="bookmark" title="Permanent Link to Developing Themes for WordPress: Part 1">Developing Themes for WordPress: Part 1</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/create-bit-ly-short-urls-for-your-posts-in-wordpress/" rel="bookmark" title="Permanent Link to Create bit.ly Short URLs for your Posts in WordPress">Create bit.ly Short URLs for your Posts in WordPress</a></li> </ul> </div> <a href="https://web.archive.org/web/20100918100854/http://www.netfirms.com/web-hosting/web-hosting-business/?a_aid=4c8bb52b19602&a_bid=8f049e07" target="_top" style="float:right;"><img src="https://web.archive.org/web/20100918100854im_/http://www.webhostrevenue.com/accounts/default1/banners/300x250-us.gif" alt="Netfirms Business Hosting Plan" title="Netfirms Business Hosting Plan" width="250" height="208"/></a><img style="border:0" src="https://web.archive.org/web/20100918100854im_/http://www.webhostrevenue.com/scripts/imp.php?a_aid=4c8bb52b19602&a_bid=8f049e07" width="1" height="1" alt=""/> </div> <div class="post"> <a href="#comment_list"></a> <div id="comments"> <h3 id="comments-title">Discussion <small> 23 Comments</small> </h3> <ol class="commentlist"> <li class="comment even thread-even depth-1" id="li-comment-2375"> <div id="comment-2375"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://0.gravatar.com/avatar/0d66c8bf6b3b2ec9b0653b44f9858ce4?s=60&d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://www.thisismyurl.com/free-downloads/easy-popular-posts/" rel="external " class="url">Christopher Ross</a></span> <span class="commentdate"> on May 21, 2009 at 9:19 am</span> </div> <div class="comment-text"> <p>Chris, this is a fantastic tutorial! You might want to add a couple quick things to your SELECT statement before the ORDER BY, “WHERE post_type=’post’ AND post_status = ‘publish’” these two limiters will ensure that the popular post is in fact a post (instead of a page) and that it’s published.</p> <p>Fantastic tutorial! Thanks for posting these.</p> </div> <div class="reply"> <a rel="nofollow" class="comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/?replytocom=2375#respond" onclick="return addComment.moveForm("comment-2375", "2375", "respond", "576")">Reply</a> </div> </div> <ul class="children"> <li class="comment odd alt depth-2" id="li-comment-3135"> <div id="comment-3135"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://0.gravatar.com/avatar/062707cfd1399d53c99bd0fd2a718224?s=60&d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://www.raymondselda.com/" rel="external " class="url">Raymond Selda</a></span> <span class="commentdate"> on June 27, 2009 at 2:03 pm</span> </div> <div class="comment-text"> <p>Nice tip on adding a couple of filters on the query. Thanks Christopher.</p> </div> </div> </li> </ul> </li> <li class="comment even thread-odd thread-alt depth-1" id="li-comment-2615"> <div id="comment-2615"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://0.gravatar.com/avatar/86e1a1b5f8d7c099fabec90c905dc9ea?s=60&d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://katzwebdesign.net/" rel="external " class="url">Zack Katz</a></span> <span class="commentdate"> on June 4, 2009 at 12:13 pm</span> </div> <div class="comment-text"> <p>I prefer the popularity contest plugin & widget, since it takes into account many more variables than just comment count, such as page views. Comment count is a good start, but not the whole ranking equation.</p> </div> <div class="reply"> <a rel="nofollow" class="comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/?replytocom=2615#respond" onclick="return addComment.moveForm("comment-2615", "2615", "respond", "576")">Reply</a> </div> </div> </li> <li class="comment odd alt thread-even depth-1" id="li-comment-3134"> <div id="comment-3134"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://0.gravatar.com/avatar/062707cfd1399d53c99bd0fd2a718224?s=60&d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://www.raymondselda.com/" rel="external " class="url">Raymond Selda</a></span> <span class="commentdate"> on June 27, 2009 at 2:01 pm</span> </div> <div class="comment-text"> <p>Very helpful tutorial. Thanks a lot for this one. Already implemented this on my homepage.</p> </div> <div class="reply"> <a rel="nofollow" class="comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/?replytocom=3134#respond" onclick="return addComment.moveForm("comment-3134", "3134", "respond", "576")">Reply</a> </div> </div> </li> <li class="comment even thread-odd thread-alt depth-1" id="li-comment-3277"> <div id="comment-3277"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://1.gravatar.com/avatar/39ab4e3e7cbaeba11b625c252b09fd45?s=60&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://adimahacita.com/" rel="external " class="url">Adi</a></span> <span class="commentdate"> on July 9, 2009 at 10:21 pm</span> </div> <div class="comment-text"> <p>Hi<br/> This tips, using comment to determine the most popular post..<br/> How if I want using the views to determine popularity?<br/> And, do you know how to show the image of the post rather than the Text Link?</p> <p>Thanks</p> </div> <div class="reply"> <a rel="nofollow" class="comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/?replytocom=3277#respond" onclick="return addComment.moveForm("comment-3277", "3277", "respond", "576")">Reply</a> </div> </div> <ul class="children"> <li class="comment byuser bypostauthor odd alt depth-2" id="li-comment-3299"> <div id="comment-3299"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://1.gravatar.com/avatar/ba043b2af6a355787f1b6fd1b1ea3eda?s=60&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://tinkerpriestmedia.com/" rel="external " class="url">c.bavota</a></span> <span class="commentdate"> on July 11, 2009 at 3:57 pm</span> </div> <div class="comment-text"> <p>I am trying to figure out how to use hits as well. As soon as I do you I will post it.</p> </div> </div> </li> <li class="comment even depth-2" id="li-comment-7849"> <div id="comment-7849"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://1.gravatar.com/avatar/ff81405bb6f989e833a8974d8d425782?s=60&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://annisaazka.com/" rel="external " class="url">abiazka</a></span> <span class="commentdate"> on February 22, 2010 at 2:47 pm</span> </div> <div class="comment-text"> <p>still waiting for this tutorial ..</p> </div> </div> </li> </ul> </li> <li class="comment odd alt thread-even depth-1" id="li-comment-3325"> <div id="comment-3325"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://1.gravatar.com/avatar/93711de34e1887478df316eb60e005bf?s=60&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://www.binarydreams.co.za/" rel="external " class="url">Lloyd</a></span> <span class="commentdate"> on July 13, 2009 at 1:12 pm</span> </div> <div class="comment-text"> <p>Thanx for this, already added it to my new project.</p> <p>Keep up the good work.</p> </div> <div class="reply"> <a rel="nofollow" class="comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/?replytocom=3325#respond" onclick="return addComment.moveForm("comment-3325", "3325", "respond", "576")">Reply</a> </div> </div> </li> <li class="comment even thread-odd thread-alt depth-1" id="li-comment-3745"> <div id="comment-3745"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://1.gravatar.com/avatar/720d76da9c74154c400dd1f7ef80a4d2?s=60&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname">jayesh patel</span> <span class="commentdate"> on August 10, 2009 at 8:15 am</span> </div> <div class="comment-text"> <p>that’s a good posting because we don’t need any plugin for showing popular post.</p> </div> <div class="reply"> <a rel="nofollow" class="comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/?replytocom=3745#respond" onclick="return addComment.moveForm("comment-3745", "3745", "respond", "576")">Reply</a> </div> </div> <ul class="children"> <li class="comment odd alt depth-2" id="li-comment-3746"> <div id="comment-3746"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://1.gravatar.com/avatar/b6158a8a1afdcfa65885653b5493e2e5?s=60&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname">jayesh patel</span> <span class="commentdate"> on August 10, 2009 at 8:22 am</span> </div> <div class="comment-text"> <p>good posting..</p> </div> </div> </li> </ul> </li> <li class="comment even thread-even depth-1" id="li-comment-4623"> <div id="comment-4623"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://1.gravatar.com/avatar/1b31dfac0e9be2a629964b459dab2f73?s=60&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://acrossparis.com/oestsetnoc/" rel="external " class="url">oes tsetnoc</a></span> <span class="commentdate"> on September 18, 2009 at 8:20 am</span> </div> <div class="comment-text"> <p>Hmmm. i want to try this one again in my site. Why is it that everything that i read in here is that i just wanted to implement them. Guess i really wanna learn huh?</p> </div> <div class="reply"> <a rel="nofollow" class="comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/?replytocom=4623#respond" onclick="return addComment.moveForm("comment-4623", "4623", "respond", "576")">Reply</a> </div> </div> </li> <li class="comment odd alt thread-odd thread-alt depth-1" id="li-comment-5913"> <div id="comment-5913"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://0.gravatar.com/avatar/01012627af79f4aee0074b30d25f8e84?s=60&d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://zacklive.com/" rel="external " class="url">Zack</a></span> <span class="commentdate"> on November 4, 2009 at 8:11 pm</span> </div> <div class="comment-text"> <p>Nice codes, clear and simple, but will unproved comments being count? What abut password protected posts? I found another codes, please let me know if there is any bugs I missed.</p> <p><a href="https://web.archive.org/web/20100918100854/http://zacklive.com/wordpress-getting-most-popularcommented-posts/589/">http://zacklive.com/wordpress-getting-most-popularcommented-posts/589/</a></p> </div> <div class="reply"> <a rel="nofollow" class="comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/?replytocom=5913#respond" onclick="return addComment.moveForm("comment-5913", "5913", "respond", "576")">Reply</a> </div> </div> </li> <li class="comment even thread-even depth-1" id="li-comment-7833"> <div id="comment-7833"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://1.gravatar.com/avatar/1ff761196054265e2b5199574aaab542?s=60&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://www.maminetz.de/" rel="external " class="url">Mami</a></span> <span class="commentdate"> on February 22, 2010 at 11:14 am</span> </div> <div class="comment-text"> <p>Wow, this one is pretty clear and simple! I used some Plugins but they do not give me the really most popular Topics out.</p> </div> <div class="reply"> <a rel="nofollow" class="comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/?replytocom=7833#respond" onclick="return addComment.moveForm("comment-7833", "7833", "respond", "576")">Reply</a> </div> </div> </li> <li class="comment odd alt thread-odd thread-alt depth-1" id="li-comment-7936"> <div id="comment-7936"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://1.gravatar.com/avatar/9fd47d31ac0359fce2079c811b6a382c?s=60&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://www.flexlearner.com/" rel="external " class="url">flexlearner</a></span> <span class="commentdate"> on February 27, 2010 at 10:13 am</span> </div> <div class="comment-text"> <p>good post,but its too complex to include her is a code better than others <a href="https://web.archive.org/web/20100918100854/http://flexlearner.com/2010/02/25/wordpress-popular-post-code/">http://flexlearner.com/2010/02/25/wordpress-popular-post-code/</a> just copy paste where ever you need and see the magic,any way keep up the good work.</p> </div> <div class="reply"> <a rel="nofollow" class="comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/?replytocom=7936#respond" onclick="return addComment.moveForm("comment-7936", "7936", "respond", "576")">Reply</a> </div> </div> <ul class="children"> <li class="comment byuser bypostauthor even depth-2" id="li-comment-7959"> <div id="comment-7959"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://1.gravatar.com/avatar/ba043b2af6a355787f1b6fd1b1ea3eda?s=60&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/" rel="external " class="url">c.bavota</a></span> <span class="commentdate"> on February 28, 2010 at 10:51 am</span> </div> <div class="comment-text"> <p>That is a fine piece of code but inline styles are not the greatest approach. Of course, copying and pasting only one block of code is always much easier but not having control over what you are pasting in kind of defeats the purpose.</p> </div> </div> </li> </ul> </li> <li class="comment odd alt thread-even depth-1" id="li-comment-8480"> <div id="comment-8480"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://1.gravatar.com/avatar/f55f04ad6e9548ff2d8ce3ef56f50741?s=60&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://rodgerfox.ru/" rel="external " class="url">RodgerFox</a></span> <span class="commentdate"> on March 25, 2010 at 6:49 am</span> </div> <div class="comment-text"> <p>good post, ths</p> </div> <div class="reply"> <a rel="nofollow" class="comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/?replytocom=8480#respond" onclick="return addComment.moveForm("comment-8480", "8480", "respond", "576")">Reply</a> </div> </div> </li> <li class="comment even thread-odd thread-alt depth-1" id="li-comment-8652"> <div id="comment-8652"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://0.gravatar.com/avatar/89dcddae1bd40a917283389838b2e441?s=60&d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://inthelimelight.net/" rel="external " class="url">Jonathan</a></span> <span class="commentdate"> on April 6, 2010 at 3:16 pm</span> </div> <div class="comment-text"> <p>This is great, just what I have been looking for. I always hate doing things with plugins that can be so easily accomplished right in the theme.</p> </div> <div class="reply"> <a rel="nofollow" class="comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/?replytocom=8652#respond" onclick="return addComment.moveForm("comment-8652", "8652", "respond", "576")">Reply</a> </div> </div> </li> <li class="comment odd alt thread-even depth-1" id="li-comment-8837"> <div id="comment-8837"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://0.gravatar.com/avatar/0c2eb02b75854c9a645dfb485e4d4713?s=60&d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://www.impresapratica.com/" rel="external " class="url">guadagnare</a></span> <span class="commentdate"> on April 19, 2010 at 11:03 am</span> </div> <div class="comment-text"> <p>Clear and simple code.<br/> But I still prefer plugins. One of the best WordPress features is indeed plugin support. What if you change theme?</p> </div> <div class="reply"> <a rel="nofollow" class="comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/?replytocom=8837#respond" onclick="return addComment.moveForm("comment-8837", "8837", "respond", "576")">Reply</a> </div> </div> </li> <li class="comment even thread-odd thread-alt depth-1" id="li-comment-9428"> <div id="comment-9428"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://1.gravatar.com/avatar/1fd18b1fe75c68392531f40a48bf9bc6?s=60&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://floads.com/" rel="external " class="url">best products reviews</a></span> <span class="commentdate"> on May 16, 2010 at 9:04 pm</span> </div> <div class="comment-text"> <p>Great job there! Took 2 minutes to implement… Gotta love wordpress tweaks! I didn’t want to use a plugin because I already have enough as it is… very simple tweak and very effective!</p> </div> <div class="reply"> <a rel="nofollow" class="comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/?replytocom=9428#respond" onclick="return addComment.moveForm("comment-9428", "9428", "respond", "576")">Reply</a> </div> </div> </li> <li class="comment odd alt thread-even depth-1" id="li-comment-10606"> <div id="comment-10606"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://0.gravatar.com/avatar/2494d339e80a2bc66ee1e6bcf8cc2950?s=60&d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://www.code-pal.com/" rel="external " class="url">Sumeet Chawla</a></span> <span class="commentdate"> on June 6, 2010 at 10:37 am</span> </div> <div class="comment-text"> <p>Awesome tutorial.<br/> I got some doubts which I am facing. What ever I wanted to do, is working fine at my localhost, but when I upload it on my host then $wpdb->get_results is returning null. Am I missing something?</p> </div> <div class="reply"> <a rel="nofollow" class="comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/?replytocom=10606#respond" onclick="return addComment.moveForm("comment-10606", "10606", "respond", "576")">Reply</a> </div> </div> </li> <li class="comment even thread-odd thread-alt depth-1" id="li-comment-11710"> <div id="comment-11710"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://0.gravatar.com/avatar/c14c5bb882b682d39e2cf212c7af7d55?s=60&d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://www.michael-louviere.com/" rel="external " class="url">Mike</a></span> <span class="commentdate"> on June 21, 2010 at 12:55 pm</span> </div> <div class="comment-text"> <p>Very nice chunk of code! I’ll use it! <img src="https://web.archive.org/web/20100918100854im_/http://bavotasan.com/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley"/> </p> </div> <div class="reply"> <a rel="nofollow" class="comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/?replytocom=11710#respond" onclick="return addComment.moveForm("comment-11710", "11710", "respond", "576")">Reply</a> </div> </div> </li> <li class="comment odd alt thread-even depth-1" id="li-comment-11864"> <div id="comment-11864"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://1.gravatar.com/avatar/30d5e72d183f691852c8b0534ccc2b90?s=60&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://www.followtheboat.com/" rel="external " class="url">Jamie</a></span> <span class="commentdate"> on June 24, 2010 at 5:00 am</span> </div> <div class="comment-text"> <p>WELL happy with this bit of code. Really easy to implement and gives me complete control. Thank you!</p> </div> <div class="reply"> <a rel="nofollow" class="comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/?replytocom=11864#respond" onclick="return addComment.moveForm("comment-11864", "11864", "respond", "576")">Reply</a> </div> </div> </li> <li class="comment even thread-odd thread-alt depth-1" id="li-comment-15982"> <div id="comment-15982"> <div class="comment-avatar"> <img alt="" src="https://web.archive.org/web/20100918100854im_/http://0.gravatar.com/avatar/46e63fb1fe27a83e913db8464479cdbc?s=60&d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G" class="avatar avatar-60 photo" height="60" width="60"/> </div> <div class="comment-author"> <span class="authorname"><a href="https://web.archive.org/web/20100918100854/http://www.vaseemansari.com/blog" rel="external " class="url">Wordpress SQL Queries</a></span> <span class="commentdate"> on September 9, 2010 at 2:13 am</span> </div> <div class="comment-text"> <p>this tutorial and query is really very nice and it can be easily used by developers, but i made some little modifications in it, that might be very helpful to get the exact data.<br/> here is the sql query that will produce better output once run in phpmyadmin<br/> SELECT comment_count, ID, post_title FROM wp_posts where `post_password`=” ORDER BY comment_count DESC LIMIT 0 , 10</p> <p>it will include only those posts which are not password protected.<br/> enjoy the tips<br/> thanks</p> </div> <div class="reply"> <a rel="nofollow" class="comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/?replytocom=15982#respond" onclick="return addComment.moveForm("comment-15982", "15982", "respond", "576")">Reply</a> </div> </div> </li> </ol> <a name="respond"></a> <div id="respond"> <h3 id="reply-title">Leave a Reply <small><a rel="nofollow" id="cancel-comment-reply-link" href="/web/20100918100854/http://bavotasan.com/tutorials/how-to-list-your-most-popular-posts-in-wordpress/#respond" style="display:none;">Cancel reply</a></small></h3> <form action="https://web.archive.org/web/20100918100854/http://bavotasan.com/wp-comments-post.php" method="post" id="commentform"> <p class="comment-notes">Your email address will not be published. Required fields are marked <span class="required">*</span></p> <p class="comment-form-author"><label for="author">Name</label> <span class="required">*</span><br/><input id="author" name="author" type="text" value="" size="30"/></p> <p class="comment-form-email"><label for="email">Email</label> <span class="required">*</span><br/><input id="email" name="email" type="text" value="" size="30"/></p> <p class="comment-form-url"><label for="url">Website</label><br/><input id="url" name="url" type="text" value="" size="30"/></p> <p>To enter code in the comment box, please place it between <strong><pre lang="php"> </pre></strong> tags. You don't have to convert any characters to their hex/HTML code. Just add your code the way you would to any code editor.</p> <p class="comment-form-comment"><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p> <p class="form-submit"> <input name="submit" type="submit" id="submit" value="Post Comment"/> <input type="hidden" name="comment_post_ID" value="576" id="comment_post_ID"/> <input type="hidden" name="comment_parent" id="comment_parent" value="0"/> </p> </form> </div><!-- #respond --> </div><!-- #comments --> </div> </div> <!-- begin sidebar --> <div id="sidebar"> <div id="search"> <form method="get" id="searchform" action="https://web.archive.org/web/20100918100854/http://bavotasan.com/"> <div> <input type="text" class="search_input" value="Search" name="s" id="s" onfocus="if (this.value == 'Search') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search';}"/> <input type="hidden" id="searchsubmit" value="Search"/> </div> </form> <div class="arrow"></div> </div> <div id="sideads"> <!-- BuySellAds.com Zone Code --> <div id="bsap_1237633" class="bsarocks bsap_8982c17d635c33dbe23a7ef930777c37"></div> <!-- END BuySellAds.com Zone Code --> <br class="clear"/> <!-- BuySellAds.com Zone Code --> <div id="bsap_1237624" class="bsarocks bsap_8982c17d635c33dbe23a7ef930777c37"></div> <!-- END BuySellAds.com Zone Code --> </div> <br class="clear"/> <div class="line"></div> <div class="side-widget"> <h4>Most Popular Posts</h4> <ul class="wppp_list"> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/creating-a-jquery-mouseover-fade-effect/" title="Creating a Mouseover Fade Effect with jQuery ">Creating a Mouseover Fade Effect with jQuery </a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/a-simple-mouseover-hover-effect-with-jquery/" title="A Simple Mouseover Hover Effect with jQuery">A Simple Mouseover Hover Effect with jQuery</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/downloads/full-sizebackground-image-jquery-plugin/" title="Full Size Background Image jQuery Plugin">Full Size Background Image jQuery Plugin</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/limiting-the-number-of-words-in-your-excerpt-or-content-in-wordpress/" title="Excerpt or Content Word Limit in WordPress: Redux">Excerpt or Content Word Limit in WordPress: Redux</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/downloads/magazine-basic-free-wordpress-theme/" title="Magazine Basic v2.6 WordPress Theme">Magazine Basic v2.6 WordPress Theme</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/retrieve-the-first-image-from-a-wordpress-post/" title="Retrieve and Display Images from a WordPress Post">Retrieve and Display Images from a WordPress Post</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/how-to-create-a-twitter-feed-on-your-web-site/" title="How to Create a Twitter Feed on Your Web Site">How to Create a Twitter Feed on Your Web Site</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/processing-multiple-forms-on-one-page-with-php/" title="Processing Multiple Forms on One Page with PHP">Processing Multiple Forms on One Page with PHP</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/downloads/6-free-vinyl-record-vectors/" title="6 Free Vinyl Record Vectors">6 Free Vinyl Record Vectors</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/gradient-buttons-with-css3/" title="Gradient Buttons with CSS3">Gradient Buttons with CSS3</a></li> </ul> </div> <div id="affiliates-ads"> <a href="https://web.archive.org/web/20100918100854/http://themes.bavotasan.com/" class="themes"></a> <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/downloads/delete-duplicate-posts-pro-wordpress-plugin/" class="deletedupes"></a> <a href="https://web.archive.org/web/20100918100854/https://secure1.inmotionhosting.com/cgi-bin/gby/clickthru.cgi?id=tinkerpriest&page=7" class="inmotion"></a> </div> <div class="line"></div> <div class="side-widget redlink"> <h4>Get a Premium Theme for FREE</h4> <p><a href="https://web.archive.org/web/20100918100854/https://secure1.inmotionhosting.com/cgi-bin/gby/clickthru.cgi?id=tinkerpriest" class="wordpress-logo"></a>Don't have a Web site? How would you like to have WordPress and a <a href="https://web.archive.org/web/20100918100854/http://themes.bavotasan.com/category/premium-themes">Themes by bavotasan.com</a> Premium theme installed and configured for <em>FREE</em>? All you need to do is <a href="https://web.archive.org/web/20100918100854/https://secure1.inmotionhosting.com/cgi-bin/gby/clickthru.cgi?id=tinkerpriest">sign up with InMotion Hosting through this link</a>. <br/> <br/> <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/free-premium-theme/" class="fr"><em>Click here for more information »</em></a> </p> </div> <div class="side-widget"> <h4>Support c.bavota</h4> <p>If you would like to support <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/">c.bavota</a> and <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/">bavotasan.com</a>, please use the donate link below. Any amount, even $1.00, is appreciated (a man's gotta eat, ya know).</p> <a href="https://web.archive.org/web/20100918100854/https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5745952" id="donate" class="fr">Donate</a> </div> </div> <!-- end sidebar --></div> </div> <!-- begin footer --> <div class="whiteline"></div> <div id="footer"> <div id="bottombar"> <a href="javascript:void(0)" class="backtotop">Back to Top<span></span></a> <div class="col col1"> <h4 class="one"><span></span>Stay in Touch</h4> <a href="https://web.archive.org/web/20100918100854/http://twitter.com/bavotasan" class="footer-twitter"><span></span>Follow me on Twitter</a><br/> <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/feed/" class="footer-rss"><span></span>Subscribe to my RSS Feed</a> <br class="clear"/> <h4 class="two"><span></span>Stay in Tune</h4> <div class="tweets"></div> </div> <div class="col col2"> <h4 class="three"><span></span>Downloads</h4> <ul> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/downloads/feed-me-seymour-free-wordpress-theme/">Feed Me, Seymour 1.2</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/downloads/magazine-basic-free-wordpress-theme/">Magazine Basic v2.6 WordPress Theme</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/downloads/sliderota-jquery-plugin/">Sliderota jQuery Plugin</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/downloads/full-sizebackground-image-jquery-plugin/">Full Size Background Image jQuery Plugin</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/downloads/easy-overlay-modal-window-jquery-plugin/">Easy Overlay Modal Window jQuery Plugin</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/downloads/snowblind-free-wordpress-theme/">Snowblind v1.1.2 Free WordPress Theme</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/downloads/8-free-colorful-background-textures-for-designers/">8 Free Colorful Background Textures for Designers</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/downloads/stationery-premium-wordpress-theme/">Stationery Premium WordPress Theme</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/downloads/illustrious-premium-wordpress-theme/">Illustrious Premium WordPress Theme</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/downloads/delete-duplicate-posts-pro-wordpress-plugin/">Delete Duplicate Posts Pro WordPress Plugin</a></li> </ul> </div> <div class="col col3"> <h4 class="four"><span></span>Tutorials</h4> <ul> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/text-rotation-css3/">Text Rotation with CSS3</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/adding-tweet-button-wordpress/">Adding a Tweet Button to WordPress</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/developing-themes-for-wordpress-make-money/">Developing Themes for WordPress: Part 5</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/developing-themes-for-wordpress-options/">Developing Themes for WordPress: Part 4</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/developing-themes-for-wordpress-the-loop/">Developing Themes for WordPress: Part 3</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/developing-themes-for-wordpress-template-file/">Developing Themes for WordPress: Part 2</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/developing-themes-for-wordpress-part-1/">Developing Themes for WordPress: Part 1</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/optimization-tips-speed-up-site/">Optimization Tips to Speed Up Your Site</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/create-bit-ly-short-urls-for-your-posts-in-wordpress/">Create bit.ly Short URLs for your Posts in WordPress</a></li> <li><a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/tutorials/optimizing-your-mysql-database/">Optimizing your MySQL Database</a></li> </ul> </div> </div> </div> <div id="copyright"> <div id="copyright-wrapper"> Copyright © 2010 <a href="https://web.archive.org/web/20100918100854/http://bavotasan.com/">bavotasan.com</a>. All Rights Reserved. Powered by <a href="https://web.archive.org/web/20100918100854/http://www.wordpress.org/">WordPress</a>. </div> </div> <!--stats_footer_test--><script src="https://web.archive.org/web/20100918100854js_/http://stats.wordpress.com/e-201037.js" type="text/javascript"></script> <script type="text/javascript"> st_go({blog:'5317602',v:'ext',post:'576'}); var load_cmc = function(){linktracker_init(5317602,576,2);}; if ( typeof addLoadEvent != 'undefined' ) addLoadEvent(load_cmc); else load_cmc(); </script> <script type="text/javascript" src="https://web.archive.org/web/20100918100854js_/http://bavotasan.com/wp-content/themes/bavotasan-2010/js/coolstuff.js"></script> <script type="text/javascript"> hs.graphicsDir = 'https://web.archive.org/web/20100918100854/http://bavotasan.com/images/graphics/'; hs.outlineType = 'rounded-white'; hs.outlineWhileAnimating = true; hs.showCredits = false; </script> <!-- Bavota San 2010 theme designed by c.bavota, http://bavotasan.com --> </body> </html> <!-- Dynamic page generated in 0.993 seconds. --> <!-- Cached page generated by WP-Super-Cache on 2010-09-17 15:52:55 --> <!-- super cache --><!-- FILE ARCHIVED ON 10:08:54 Sep 18, 2010 AND RETRIEVED FROM THE INTERNET ARCHIVE ON 14:36:18 Nov 26, 2024. JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. SECTION 108(a)(3)). --> <!-- playback timings (ms): captures_list: 0.776 exclusion.robots: 0.042 exclusion.robots.policy: 0.024 esindex: 0.016 cdx.remote: 17.773 LoadShardBlock: 196.008 (3) PetaboxLoader3.datanode: 91.63 (4) PetaboxLoader3.resolve: 249.264 (3) load_resource: 219.153 -->