The following snippet can be used to show the posts with the highest number of comments. It displays the posts in a list, but could easily be customized. <?php $popular_posts = $wpdb->get_results(“SELECT id, post_title, comment_count FROM {$wpdb->prefix}posts WHERE post_type=’post’ ORDER BY comment_count DESC LIMIT 10″); ?> <ul> <?php foreach($popular_posts as $post) : ?> <li> <?php [...]
WordPress Code Snippets
Code snippets are a simple way to add features and functionality to your WordPress website. They are just a cut-n-paste away. Here is a collection of the most useful WordPress snippets on the Internet.
Add an Edit Link to your Posts and Pages
Displays a link to edit the current post, if a user is logged in and allowed to edit the post. It must be used within The Loop. <?php edit_post_link(__(‘Edit This’)); ?> Source



