Display your average comments per wordpress posts

February 9, 2009

Do your blog gets a lot of comments? Here is an easy way to know the average comments per posts on your WordPress blog, using new functions introduced in WordPress 2.7. Simply paste the following code anywhere on your theme, where you’d like the average comments per post to be displayed: <?php $count_posts = wp_count_posts(); $posts = $count_posts->publish; $count_comments = get_comment_count(); $comments = $count_comments['approved']; echo "Average ".round($comments/$posts)." comments per post."; ?> This code... [Read the full story]

Number your wordpress comments

February 3, 2009

Do your blog posts receive lots of comments? If yes, it can be really useful for both you and your readers to number it. Here’s how to do it easily and efficiently. Open comments.php and find the following line: <?php foreach ($comments as $comment) : ?> Just below this line, initialize a counter variable: <?php $i = 0; ?> Just after this line, increment the counter: <?php $i++; ?> Now, you just have to echo the $i variable to get the number of the current comment. Paste this code anywhere on your comments... [Read the full story]

Display the most commented posts of one year

January 4, 2009

To get started with new year, what about displaying a list of the 10 most commented posts of 2008 to your readers? That’s obviously a great way to give a second life to your old posts. To display a list of your 10 most commented posts from 2008, simply paste the following code on your blog sidebar, or anywhere on your theme:   <h2>Most commented posts from 2008</h2> <ul> <?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title, post_date FROM $wpdb->posts WHERE post_date... [Read the full story]

Remove curly quotes from your wordpress comments

January 4, 2009

How to remove curly quotes on your comments? Simply paste the following line of code on the functions.php file from your theme. remove_filter('comment_text', 'wptexturize'); That’s easy as that!  Read More →

Style author comments in WordPress 2.7

December 31, 2008

Due to the new comments system in WordPress 2.7, and the wp_list_comments() function, you have to change the way you style author comments. With previous WordPress versions, you had to use some hacks to be able to give a special style to author comments. But this isn’t needed with the brand new WordPress 2.7: A specific CSS class is automatically added by WP to author and registered users comments. To style author and registered users on WordPress 2.7, simply paste the following code in your style.css file, and style at... [Read the full story]