WordPress Hack: Change Number Of Comments Per Page In Admin Interface
WordPress is displaying 20 comments per page in the admin interface. This might not be a problem for users who usually get a handful of comments per day but it forces webmasters with hundreds of comments per day to flip through the pages quite often. The 20 comments per page figure is actually the figure for both the approved comments and the comments identified as spam.
Another thing that is really annoying in WordPress 2.7 is the fact that you can either delete all comments on the page, selected comments or all spam comments at once. At 20 spam comments per page and thousands in total this can take a long time to flip through and delete.
The WordPress hack is actually quite easy to perform even for webmasters who have no knowledge whatsoever regarding html and php. The file that is responsible for the amount of comments that are displayed is called edit-comments.php. It can be found in the wp-admin folder. Make sure you backup that file before you apply the changes so that you can revert back if something should go wrong.
Locate the following line in the file, it should be around line 182 in the file:
$comments_per_page = apply_filters('comments_per_page', 20, $comment_status);
The only thing that you need to do is to change the figure 20 to another figure, e.g. 100 so that it looks like this:
$comments_per_page = apply_filters('comments_per_page', 100, $comment_status);
Just save the file again and check the display of the comments in the admin interface to make sure everything is working correctly.
Update: Newer versions of WordPress support this feature natively, so that it is no longer necessary to make changes to WordPress core files.
All you need to do is click on Screen Options at the top right of the comments page, and change the number of comments per page to another value.
Advertisement
To everyone you most likely are yourself, but yet to particular you most likely are the.
sarenza bottes http://www.chile62sarenza.com/
Pretty sure this can be done via the screen options tab now.
You are right, it is now possible to do that. Back in 2008, it was not available.
My bad. I just saw the last comment was from this year and didn’t realize the post was from 2008…
I have updated the article to reflect that though, so thanks for pointing me in the right direction.
Please don’t make edits to the core of WordPress. This is exactly what the filter is there for. A filter let’s you modify the value before it is used, and make that modification from your theme so the change isn’t lost when you upgrade.
Put this in your functions.php file in your theme:
add_filter( ‘comments_per_page’, ‘custom_comments_per_page’ );
function custom_comments_per_page() {
return ‘100’;
}
Change 100 to whatever number you want.
+1 to what Bill Erickson said; please don’t suggest hacking the core as the mods will be lost the next time someone upgrades. Use the hook like Bill showed instead.
Friend, this was very helpful even for a novice like me. Thanks.
Page Bookmarked, thnaks for sharing!
I heart you! THANKS! You save me HOURS of work!
You saved my day, thanks!
Thanx Martin. Like you said this one is easy but a heavily hacked WordPress install has at least the potential of lots more work every time there is an update. I keep having to write down what I have done, at least most of the things I have done so far are in specific theme folders so they are sometimes unaffected with security or minor upgrades.