Display the number of comments on each wordpress post

December 16, 2008

How we can display the number of comments for each posts? While some themes do it by default, most of them don’t display it at all. To solve this problem, simply open your index.php file and paste the following code within the loop: <?php comments_number('No comments yet','1 comment','% comments')?> Even better, following code have a link to jump directly to the comments: <a href="<?php the_permalink() ?>#comments"><?php comments_number('No comments yet','1 comment','% comments')?></a>  Read More →

Deny wordpress comment posting to no referrer requests

December 3, 2008

If you’re a WordPress user, then you’re probably upset with the amount of daily spam comments. Sure, there’s akismet, but here’s a little .htaccess trick to prevent spammers posting on your wordpress blog. Simple paste the following code on your .htaccess file, located at the root of your WordPress install. Don’t forget to specify your blog url on line 4. Remember to ALWAYS create a backup when editing the .htaccess file. RewriteEngine On RewriteCond %{REQUEST_METHOD} POST RewriteCond %{REQUEST_URI} .wp-comments-post\.php* RewriteCond... [Read the full story]

Disable commenting on wordpress posts older than 30 days

November 25, 2008

Sometimes, it can be useful to automatically disable commenting on posts older than X days. There’s no built-in function in WordPress to do that, but if you still like to do it, just read this article. To enable auto comment closing, simply paste the following function on the functions.php file from your theme. If that file doesn’t exists, create it. You can easily change the number of days after posts can’t be commented by changing 30 to X on line 3 of the close_comments() function. <?php function close_comments(... [Read the full story]

Create a wordpress 2.7 compatible comments template

November 20, 2008

WordPress 2.7 includes a lot of new enhancements, but one of the big ones is the new comment functionality. Comments can be threaded, paged, etc. This is all built in, but unfortunately, your theme must support it. So, for theme authors, I’d suggest getting to work on making your themes compatible right away. How to create a wordpress 2.7 compatible comments.php If you want your theme to be backward compatible as well, then there’s a simple way to do it. Just check for the wp_list_comments function, like so: if (function_exists('wp_list_comments'))... [Read the full story]

Display wordpress Recent Comments Without Widgets

November 18, 2008

We know that you can easily display the recent comments with the help of a sidebar widget (If your WordPress blog supports widgets) but there is a simple solution that you can use to display recent comments without widgets, the following code will allow you to execute the recent comments in your blog anywhere in your template without widgets. Two primary features: It allows you to display recent comments without widgets. It lets you control how many recent comments to display. Firstly, open a new text file and place the... [Read the full story]