WordPress Hack: Change Number Of Comments Per Page In Admin Interface

Martin Brinkmann
Dec 17, 2008
Updated • May 29, 2012
Internet
|
14

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.

wordpress comments per page

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

Tutorials & Tips


Previous Post: «
Next Post: «

Comments

  1. sarenza bottes said on October 28, 2012 at 4:18 pm
    Reply

    To everyone you most likely are yourself, but yet to particular you most likely are the.
    sarenza bottes http://www.chile62sarenza.com/

  2. WordPressForge said on May 29, 2012 at 12:41 pm
    Reply

    Pretty sure this can be done via the screen options tab now.

    1. Martin Brinkmann said on May 29, 2012 at 2:32 pm
      Reply

      You are right, it is now possible to do that. Back in 2008, it was not available.

      1. WordPressForge said on May 29, 2012 at 2:49 pm
        Reply

        My bad. I just saw the last comment was from this year and didn’t realize the post was from 2008…

      2. Martin Brinkmann said on May 29, 2012 at 3:20 pm
        Reply

        I have updated the article to reflect that though, so thanks for pointing me in the right direction.

  3. Bill Erickson said on August 26, 2011 at 4:13 pm
    Reply

    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. Mike Schinkel said on March 19, 2013 at 12:17 am
      Reply

      +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.

  4. M H Jowher said on July 16, 2011 at 12:43 pm
    Reply

    Friend, this was very helpful even for a novice like me. Thanks.

  5. Infographiste said on February 2, 2010 at 1:17 pm
    Reply

    Page Bookmarked, thnaks for sharing!

  6. ultraspy said on January 14, 2009 at 3:12 pm
    Reply

    I heart you! THANKS! You save me HOURS of work!

  7. Adrian Kuhn said on December 28, 2008 at 7:58 am
    Reply

    You saved my day, thanks!

  8. RG said on December 17, 2008 at 7:21 pm
    Reply

    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.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.