Posted by KaiseRCrazY on 25th July 2009
Popular Posts, Without any Plugin!
Hi everybody, you can show your most commented popular posts wtihout any plugin. It’s a simple code. Easy useable and appliable. We will edit siderbar.php or single.php. Where you want to show popular posts, you can edit any file. If you are ready, Lets begin…
Here is the code;
<h2>Popular Posts</h2>
<ul>
<?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5");
foreach ($result as $post) {
setup_postdata($post);
$postid = $post->ID;
$title = $post->post_title;
$commentcount = $post->comment_count;
if ($commentcount != 0) { ?>
<li><a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>">
<?php echo $title ?></a> {<?php echo $commentcount ?>}</li>
<?php } } ?>
</ul>
If you want to make a Popular Post Widget, you can use this code on sidebar.php or if you want to show this after post, you have to add this code after loop in single.php.
If you change the number “5” you can change Popular Posts Number :)
That’s All! Have a nice day.
- Wordpress
Filed Under
Post your comments
-
Categories
Tags
sor_column Popular Posts old posts archive.php month color visitors colored tag cloud funciton buttons system functions.php Google adsense del.icio.us hide echo wp_posts button bandwith funcitons exploit archive template reddit tweet categories link question function_exists word count visitor categories in two columns Premium themes output share on facebook phpmyadmin archive manager auto save kaisercrazy functioıns non-complex future posts link change contact form 7 feedburner comment compress core file header.php solution dashboard fetch feed login panel generator modify furl first image widgetize content firefox if thumbnail title php sidebar writer social bookmark list category source non-premium themes category usage Google post attachments body sql post editor subscribe spiders private .htaccess security hole crawl reCAPTCHA spped up your blog show rss have_posts doctype article title exploit scanner menu area WP searched text request the_loop integrate java Platinum SEO Pack tim thumb delay time Wordpress search theme edit ads comment list yoast page elseif bubletooltips tooltip Udegbunam style.css author randomize archives wp_nav_menu Wordpress footer links trick response time edit IE6 magazin style show mood Facebook tabs Turkey rewiew article robots captions editor scheduled social bar ie guest more link happy new year security scan first template Yahoo posts theme develop moderate disable captions contact plugin writer sticky posts div plugin changes fallback_cp date button easy life wp_categories_menu breadcumbs queries comments.php feed wp-admin menu sistemi attachment comment number user_login bio steal extra area protect WpFunc change theme spam free returning wthout plugin search terms single.php SEO time wprecipes Blogroll search engine tutorial schedule comment editing comments.php hacks Serkan Algur commenting code image comments Twitter safari RSS highliht sliding change menu long titles menu_order recent commen ns4 custom field hotlinking highlight new year css jquery browser detect theme protected XHTML tags theme_location Functions featured no-index disable Widget remove menu search term WorPress function vectorss disable caching more nickname server shortcode wp_page_menu update version index.php query post_status social article numbers sidebar.php collection weekly description footer.php hide content spam commets recipe timestamp plugins hyperlink message delay date expration short title single image upload style close dropdown menu XHTML social networks else command problem holiday iphone mood hidden file year zlib library get image blog stats publish time javascript author name without plugin highlight searched text post date inline comments me upgrade system health google xml sitemaps 2010 comment form post featured.php Joomla wordpress forums file day sql injection Settings vuvuzela footer wordpress dashboard today newsletter blog security links post_type Tinymce area wp version customizable titles 2009 db blog archives.php category_description custom title login name NeoEase PDF site noindex ie8 html chrome login form google docs CMS delicious comment_cookie 15 days old digg random post wordpress 3.0 database didim jump link Related posts mysql Loop hacks revision firewall remove rss feed searchRecent Comments
- John, sorr... »
- John on Catch the First Imagenevermind ... »
- John on Catch the First ImageWhere do y... »
- ok, thank ... »
Archives
Blogroll
Google Ads















Made by Symmetric Web
Distributed by Smashing Magazine
2 Responses
[...] Here is the original: Popular Posts, Without any Plugin! [...]
[...] Read more: Popular Posts, Without any Plugin! [...]