WordPress Paged Comments Plugin

This plugin is no longer being developed. WordPress has had paged comments support in the core since version 2.7. The comment paging you see here is using WordPress’s built-in code and not my plugin.

Paged Comments is a plugin for WordPress to allow comment paging. Useful for those popular blog entries receiving many comments, or a simple guestbook page within WordPress.

Features

  • Comment ordering: show latest comments first, or last
  • Specify number of comments to display per page
  • Enable paging for all posts and pages, or on a per-post basis
  • Give users the choice to view all comments on one page with a ‘show all’ link
  • Specify the first or last page of comments to load by default
  • See paged-comments-config-sample.php for more

Download — Latest Version

Installation (for WordPress 2.3 up to 2.7)

If you’re upgrading from a previous version, skip these installation steps and read the upgrade steps. Note: WordPress’ automatic upgrade feature will erase the plugin’s config file. If you’re going to use it, make sure you backup your paged-comments-config.php file first.

  1. Download and extract plugin files to a folder locally.
  2. Read through and edit paged-comments-config-sample.php to configure, then save the file as paged-comments-config.php.
  3. Upload the whole paged-comments directory to /wp-content/plugins/. The plugin files should now be in /wp-content/plugins/paged-comments/.
  4. Enable the plugin through the WordPress admin interface. That’s it!

Optional Steps

  • WP 2.7 users: If use_wp_config is set to true (default), you can make changes to the plugin config using the WP admin interface. Go to Settings > Discussion and look under ‘Other comment settings’.
  • To customise the template to work better with your theme: Open the plugin’s themes folder and find the subfolder corresponding to the WordPress theme you’d like paged comments enabled on (or if your theme isn’t listed, choose the ‘default’ folder). Upload comments-paged.php to the appropriate WordPress theme folder (found in [wordpress]/wp-content/themes/).

    For example, if you’re using the default WordPress theme, copy [paged-comments-plugin]/themes/default/comments-paged.php to [wordpress]/wp-content/themes/default/. (The plugin always tries to load comments-paged.php from your active theme folder first.)

    Make any modifications to comments-paged.php. The file is based on the comments.php file, so if your theme is very different it might be easier to copy in the necessary elements from paged-comments.php. View the diff report to see what you need to change.

Examples of Use

The comments on this page are handled by the plugin, but it’s also used by the following sites:

Questions?

Paid Support

If you run a commercial site and you’re having difficulty setting up paged comments, I offer paid support. Feel free to get in touch: keyvan (at) k1m.com

45 Comments

  1. mary says:

    Nice plugin. Thanks!

  2. Taimur Khan says:

    I installed the plug-in and it was working well for all the test comments I posted, except for the fact that when I posted the 11th comment, the last ten disappeared and there was no page number visible through which the previous comments could be accessed. The number of responses, etc. was all there but the previous comments that had be relegated to another page were simply not accessible as there was no comments page number visible. I have disabled the plug-in on my site for now but would really like to have it for my Guest Book.

    Could you please tell me what is the code for comment page number and where does it reside?

    Thank you.

  3. Keyvan says:

    Taimur, the comments-paged.php template file pulls in the page numbers. Here’s a snippet from comments-paged.php (taken from the plugin’s /themes/default/ folder):

    <!-- Comment page numbers -->
    <?php if ($paged_comments->pager->num_pages() > 1): ?>
    <p class="comment-page-numbers"><?php _e("Pages:");?><?php 
    paged_comments_print_pages(); ?></p>
    <?php endif; ?>
    <!-- End comment page numbers -->

    The best thing to do is enable the plugin, load up the page you’re expecting the page numbers to appear on, and look through the HTML source for the page numbers.

    Let me know if you’re still having problems with the plugin.

  4. Keyvan says:

    Left that last comment unfinished, sorry. If you do find the page number in the HTML source, but they don’t appear when you’ve viewing the page, then the theme you’re using probably has CSS rules affecting the display of the page numbers. If that’s the case, let me know what theme you’re using and I’ll take a closer look.

  5. Taimur Khan says:

    Thank you for the quick reply! Yes, the code you mentioned exists in the comments-paged.php file.

    I have enabled the plug-in again and made 12 test posts on this page: http://www.sarangi.info/archives/91

    The descending order of posts has been put into effect by the plug-in but the page numbers do not appear.

  6. Keyvan says:

    Taimur, I don’t have much time to look into this now. Will try and see what the problem is tonight. I had a quick look at your page’s HTML source and it does not include the page numbers (so no CSS interference). Are you sure you’ve followed all the installation steps? If you are using one of my bundled templates your HTML source should include the comment numbers. I’ll have another look tonight.

  7. Taimur Khan says:

    I am also using the static frontpage plug-in by Semiologic. Do you think that could interfere with comment page numbers?

    Anyway, thank you very much for your time. I hope I can find an easy solution with your help. Otherwise, please don’t waste too much time on my case.

    Warm regards,
    Taimur.

  8. Taimur Khan says:

    I use the Default Kubrick theme and did not want this text to appear on my posts pages:

    “This entry was posted on Wednesday, November 16th, 2005 at 12:00 pm and is filed under Events. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site. Edit this entry.”

    So I excluded the following script from my single.php file:

    This entry was posted
    post_date) - (60*120)); echo time_since($entry_datetime); echo ' ago'; */ ?>
    on at and is filed under .
    You can follow any responses to this entry through the feed.
    comment_status) && ('open' == $post->ping_status)) {
    // Both Comments and Pings are open ?>
    You can <a href="#respond" rel="nofollow">leave a response</a>, or <a>" rel="trackback">trackback</a> from your own site.
    comment_status) && ('open' == $post->ping_status)) {
    // Only Pings are Open ?>
    Responses are currently closed, but you can <a> " rel="trackback">trackback</a> from your own site.
    comment_status) && !('open' == $post->ping_status)) {
    // Comments are open, Pings are not ?>
    You can skip to the end and leave a response. Pinging is currently not allowed.
    comment_status) && !('open' == $post->ping_status)) {
    // Neither Comments, nor Pings are open ?>
    Both comments and pings are currently closed.

    Not only did the above-mentioned text disappear as desired, the paged comment fuction with all the page and comment numbers, etc. started to work normally for me as well. I don’t know why that happened but it did, and I am very happy. Thank you for this excellent plug-in!

  9. Keyvan says:

    Hi Taimur, I have to admit I’m still a bit baffled as to why it wasn’t working before. It could be that the other plugin was interfering and caching the page – preventing the display of the dynamically generated comment page number – but I really can’t be sure until I try it. I’m glad you’ve managed to get it to work. If you experience any other strange problems, let me know and I’ll try running the two plugins side-by-side myself to see what it could be. Thanks for the update!

  10. Taimur Khan says:

    Yes, it’s working well now:
    http://www.sarangi.info/archives/91

    Using the Static Frontpage plug-in by Semiologic is not a problem as I even tried turing it on and off to no avail, and am using it still. The paged comments plug-in started working normally only when I deleted the script from the single.php for quite another reason (mentioned in my last response) – mere coincidence it was…

  11. Florian says:

    Hello Keyvan,
    sorry but the plugin is not working for me. I always get the message: “Sorry but comments are closed…” when I activate it, but that’s not true. I activated all comment options but it won’t work.

    Any Ideas?

  12. Florian says:

    Hm, I figured it out, works now. Thank’s anyway!

  13. Has this plugin been updated and tested to successfully under WordPress 2.0?

  14. Keyvan says:

    Aaron: Not yet. I will be testing it as soon as I get the chance. (If anyone else has tried running it under WP2, please post up and let me know.)

  15. Jonathan says:

    Great plugin, I’ll definitaly make use of it when I change my guestbook over to WordPress.

    I have found just one slight problem. A really nice feature of WordPress comments is way new comments appear to the person who submitted them with the label “Your comment is awaiting moderation”, while no-one else can see them. With your paged comment plugin, this no longer works. The comment is completely invisible to everyone until it has been approved.

    I fixed this by copying the necessary code to checks the user’s name and e-mail from comment-functions.php

  16. Keyvan says:

    Hi Jonathan,
    Thanks for flagging this up. You’re right that it’s a useful feature. I’ve just tried to think of my original reason (it was intentional) for disabling it, but I can’t remember it now. 🙂 I think I did consider adding it as an option, so it wouldn’t have been a serious issue. Hmmm, if the reason doesn’t come to me soon I’ll work it back into the next version. Thanks again for raising the issue.

  17. […] Several plugins that might be useful if my post readership increases by several orders of magnitude: 1) WordPress Email Notification. If readership includes non-blogophiles who don’t know an RSS feed from a pig trough. http://watershedstudio.com/portfolio/software/wp-email-notification.ht ml 2) Subscribe to Comments. Allows readers to subscribe to the comments of a post by email, and manage their subscriptions. Ditto to previous for comments. http://www.scriptygoddess.com/archives/2004/06/03/wp-subscribe-to-comm ents/ 3) Paged Comments. Allows comments to be split across multiple pages. http://keyvan.net/code/paged-comments/ […]

  18. Chris Eilers says:

    Thanks for a great plugin, which I’ve installed on a trial blog at http://www.onlineresumesandcvs.com/blog/. Have also installed the code for excluding the blog entry on follow-on comment pages that you wrote for Massimo.

    Is there an equally simple way of excluding a postmetadata paragraph (on copyright and the post date of the blog entry) on the follow-on comment pages?

    I’ve got a number of other questions of lesser importance, and don’t mean to take you away from your Ajaxing, which looks promising. 🙂

    Is there an easy way to insert the_title() into the else statement you wrote above? I tried the following but the title doesn’t display:

    <?php if (!isset($_GET['cp'])) {
      the_content('<p>Read the rest of this entry</p>');
    } else {
      echo '<p>You are browsing a page of comments on “<?php 
        the_title(); ?>”. Read “<?php the_title(); ?>” <a href="', 
        get_permalink(), '">here</a>.</p>';
    } ?>

    Can “(Show All)” be included in your (current, stable, non-Ajax) plugin? I notice you have “(Show All)” as well as numbered links on your main plugin page at http://keyvan.net/code/paged-comments/, and I think this could be useful for some users.

    Is it possible to remove the comments box (and associated code) from all except the (most-recent) comment page?

  19. Tim says:

    I tested your plugin with wordpress 2.0.
    It seems to be working fine, except for the rewrite rules. They are broken and result in 404 errors. Updated rules would be appreciated.

  20. jakob says:

    hi k

    in wp2.0 the url-rewrite messes up, can you fix.

    have a look here

    rgds
    jakob

  21. Dayna says:

    This is a very useful plugin. 🙂

    Is there any way to fix the issue about the rewrite rules? I’m using WordPress 2.0

    Thank you.

  22. Keyvan says:

    WordPress 2 URL fix:

    Open paged-comments.php and find the ‘=== END EDITING ===’ lines. After the two lines paste the code below. In WP2 the rules for determining the requested page/post have been moved out of the .htaccess file and into PHP code. I couldn’t figure out the best way to hook into the rewrite process, so I’ve opted for a simpler approach: before WP’s parse_request kicks in, we look for the URL segment identifying the comment page, note the comment page number and strip it out of the REQUEST_URI so WP doesn’t kick up a fuss when it comes to parse the request itself. I’ve not tested this extensively, so please treat with care and report any problems. Thanks. (Still a bit rushed so not had a chance to release a new version or update the instructions.)

    Note: If you’re setting this up on WP2, please disregard step 7 as it’s no longer required. (In fact, the new rewrite rule in WP2 matches pretty much any URL structure so the additional rules in step 7 won’t even be evaluated if you do include them.)

    if ($paged_comments->fancy_url) {
        add_action('init', 'paged_comments_fancy_url');
    }
    function paged_comments_fancy_url()
    {
        $req = rtrim($_SERVER['REQUEST_URI'], '/');
        if (preg_match('!^(.+/)comment-page-([0-9]+)$!', $req, $match)) {
            $_GET['cp'] = $match[2];
            $req = $match[1];
        } elseif (preg_match('!^(.+/)all-comments$!', $req, $match)) {
            $_GET['cp'] = 'all';
            $req = $match[1];
        }
        $_SERVER['REQUEST_URI'] = $req;
    }

    You can view the changes in the project’s trunk at the WP Plugin Repository.

  23. Dayna says:

    Hi Keyvan,

    I’ve tested out the fix you’ve given on my WordPress 2.0 and there’s no problem with it, working great. Thank you 🙂

  24. Keyvan says:

    Thanks for reporting back Dayna! Good to know it’s working for you. Hope it does for others as well. 🙂

  25. Dayna says:

    Hi, I’m here again, I’ve got a minor question.

    The comments number is a bit odd now.

    http://liberta.espoireve.com/essence/guest-book/comment-page-2/

    The comments number starts with 1 for the latest comment, if you click on page 1, the first comment is still 1.

    I’m using this code by CodeForged to generate the comments number, is there a way to fix it.

    Thank you.

  26. Tim Boucher says:

    This looks like an awesome plugin! Thanks for all the work you’ve done on it, Keyvan.

    I have a question about a possible modification though. If you point me to any possible resources to help me out, I’d appreciate it. What I’m looking for is very similar to what you’ve done here with a few small differences.

    (1) By default, all comments would be shown on a post page, and the paging would come into play as described below.

    (2) I’d like for the permalink for a comment to point to an individual comment page. The comment page would feature the title and excerpt from my original post, plus some text that says “This is a comment page, etc etc”. And then there would be buttons that say “view all comments,” “leave a comment,” and “Previous” and “Next.”

    Does this sound like something I could easily build based on your existing plugin code, or would it require a lot of changes? I don’t have a ton of raw PHP programming experience, so any pointers and resources you could throw my way would be very much appreciated. An email or response here would be great!

  27. […] Paged Comments – very sueful if you have entries with hundreds or even thousands of comments. […]

  28. Keyvan says:

    Hi all, I will respond to the questions, but I still need a few more days.

  29. […] Overall, it’s probably not the world’s hardest plugin to build, especially since you might be able to re-purpose some of the code from Keyvan’s paged comments plugin (which is sort of similar, but not quite). If there’s anybody who’d like to help a brother out with this, let me know. I don’t really have any money to throw at you, thanks to my upcoming move. But maybe we could trade a little bit of freelance design, or some kind of other arrangement. Or you could do it just cause you like me so much and want to help a brother out. That works too! Either way, drop me an email. Thanks! Read Similar Articles: […]

  30. Aleister says:

    Very nice plugin. Just what I was looking for. Works great! 🙂

  31. BloggingTom says:

    WP Paged Comments Plugin

    Kommentare zu Postings können manchmal ganz schön unübersichtlich werden, und mit der Anzahl der Kommentare steigt auch die Ladezeit der Seite. Dies ist auch beim Post “Die Eypo AG schlägt zurück“, einem der beliebtesten Artikel auf d…

  32. […] Split things up – I’m sure you’ve all been to a post which has hundreds of comments and it takes forever to load. Paginate your comments once there’s too many to load on a single page. […]

  33. Dayna says:

    Hi Keyvan,

    Thanks for updating this plugin so that it’s working great with WordPress 2.0. I wanted paged comments for all my pages not posts, is it possible to add an option for it so that I don’t have to add the custom field to all my pages?

    Thank you.

  34. Sanjay M says:

    Thank you very much for your plugin, I’m finding it very useful for my site. It really speeds up page access by limiting the page size and is a big boon! 🙂

  35. Hi Keyvan,

    The plugin looks awesome!

    But I’m having no luck getting to work:

    WordPress 2.0, Connection-Reloaded v1.2.2 Theme (sort-of)

    I’ve installed the bits in the proper places, and I’m using the “comments-paged.php” from the Default folder. I’ve also renamed paged-comments-config.php.

    I think it’s the replacement of comments_template()that the problem.

    The Connection-Reloaded them has:

    single.php
    page.php
    pages.php

    page.php does not contain any invocation oh comments_template(), pages contains one (which I replaced).

    With the plugin activated, I see no effect. I have a post with 12 comments, no pagination, and the main index seems to have some basic pagination that has nothing to do with your file.

    I’m stumpped!

    Thanks for your time (and the plugin!)
    Sean Hyde-Moyer

  36. Keyvan says:

    Sorry for the late reply. I’ll try and answer a few of the questions…

    Chris: I’ve tried to answer some of your questions on the FAQ.

    If you’re still having trouble with inserting the title, it’s likely to do with the use of <?php> tags in your code snippet. Try changing

    <?php if (!isset($_GET['cp'])) {
      the_content('<p>Read the rest of this entry</p>');
    } else {
      echo '<p>You are browsing a page of comments on “<?php 
        the_title(); ?>”. Read “<?php the_title(); ?>” <a href="', 
        get_permalink(), '">here</a>.</p>';
    } ?>

    to

    <?php if (!isset($_GET['cp'])) {
      the_content('<p>Read the rest of this entry</p>');
    } else {
      echo '<p>You are browsing a page of comments on "',
      the_title('','',false), '". Read the full story <a href="', 
        get_permalink(), '">here</a>.</p>';
    } ?>

    (The arguments to the_title() ensure the value is returned and not printed, your echo statement does that for you.)

    I know you had some other questions, if you’d still like me to have a go at answering them, let me know. (This reply is quite late so you might have figured out the solution to the other problems by now.)

    Tim: What you’re asking for is possible, but I don’t have the time to do it myself. Setting the comments per page value to 1 should show you one comment per page. This will also give you a URL for each comment, but these URLs won’t be very reliable as permalinks—deleting one comment will affect the page numbers and therefore the permalink. Ideally you’d want the comment ID (which currently appears as a fragment identifier of the URL) to be part of the URL as a path segment.

    Dayna: Thanks for the suggestion. I’ll include an option in the next version. Here’s one solution you can use now. If your theme has a separate template file for pages (the default theme has single.php and page.php) you can edit single.php and remove the call to paged_comments_template() (to return it to the state it was in prior to step 5). This will remove paging from all posts and will bypass the Paged Comments plugin completely.

    Sean: Can you provide the URL of the post with comments on. If Paged Comments is not enabled through the admin panel then everything will work as before. If you give me a URL I can check to see from the HTML source if the comments-paged.php template file is being used or not.

  37. Got it!

    There was a readme in the Themes>Default folder:

    ADDITIONAL NOTES:

    You can enable commenting on pages by adding the line:

    php if (function_exists('paged_comments_template'))
         paged_comments_template(); else comments_template(); 

    above the php get_sidebar(); line in page.php

    Following this additional step made it all good.

    Now I just have to figure out why it nuked my live preview window…};^)

  38. Dayna says:

    Thanks loads Keyvan. Got it working already! =)

  39. Keyvan says:

    Sean: The plugin uses the comments-paged.php template instead of comments.php. If you’re careful, you can open the two templates (comments-paged.php and comments.php) side by side and try to move over the code from comments.php to comments-paged.php (while preserving the plugin-related code).

    When I get more time, I’ll write a brief guide for theme authors, showing how to build a comments-paged template. (It’s not too difficult to figure out by looking at the code).

  40. Vinu says:

    Boss,
    Cal i have a copy of this Theme “keyvan”?

    Thanks alot for the Plug-in…
    Can we add more fields? like Location, Gender…etc?

    Vinu

  41. Kenny says:

    I’m noticing people starting to complain about Ajax plugins and how it makes sites slow. I my self have noticed running more than a couple ajax plugins that my site starts to crawl while loading the java calls in the header. Are you going to do away with the non ajax paged comments plugin? Good work either way.

  42. Keyvan says:

    Vinu: I don’t have the theme packaged up, and never intended to distribute it, but feel free to use the CSS if it’s for non-commercial use.

    Extra fields I think are best left to another plugin.

    Kenny: Thanks for the comment. I’m not too fond of Ajax myself. The non-Ajax version will remain and if/when I get time to integrate an Ajax mode, it will fall back to non-Ajax mode when an unsupported browser is encountered. And, of course, there’ll be an option to disable Ajax completely.

    The Ajax version will also only be compatible with WordPress 2. I haven’t looked into WP2 much, but as far as I know it comes bundled with Javascript libraries that plugins can make use of. If that’s the case, it’ll save me having to supply JS files and saves users time if the WP2 JS files are being shared (and loaded only once).

    I’ve not had much time lately to work on the Ajax version, so I don’t think I’ll have a release ready anytime soon.

  43. Guig says:

    Hi, I was wondering how to apply this plugin to popup comments.

  44. Keyvan says:

    Guig, I’m afraid I don’t know. I’ve never tried popup comments. I’ll look into it when I get a chance.

  45. 082net says:

    Hi Keyvan,

    First of all, thanks for your great work. I’m so appreciated.
    I made a modified version of ‘Threaded and Paged Comments(by Trustin)’ plugin, and named it ‘tp-guestbook’.

    It’s based on ‘Paged comments(Yours)’ and ‘Brian’s Threaded Comments’.

    I tried to send a trackback, but my post is in ‘korean'(I’m not so good at english) 🙁

    You can check it Here

  46. Keyvan says:

    Hi 082net, thanks for the work—it looks very good. I’ve included a link in the related downloads section above. I still haven’t got round to installing Trustin’s plugin, but when I do, I’ll try this as well.

  47. 082net says:

    I’m pleased to see the link included on this page.
    I never thought that 🙂

    Thanks for those good words to my work.
    (Is this right expression?…I hope)

  48. tanster says:

    Hi Keyvan,

    Thanks for a great plugin!

    Have a question: my comment numbering is not correct when I use ordering = DESC + fill_last_page = true.

    Here’s what I have:
    • A post with 12 comments
    • Config settings:
    all_posts = true
    per_page = 10
    ordering = desc
    page_range = 5
    fancy_url = false
    show_all_option = true
    fill_last_page = true
    • WordPress 2.0 + Default Theme + unchanged Default comments-paged.php + no fancy permalinks

    What I see:
    • Comments page 2 is INCORRECT: Newest comment is numbered “20”, with comments that appear below it on the same page numbered 19-11 (newest comment should be numbered “12”, with comments that appear below it on same page numbered 11-3)
    • Comments page 1 is CORRECT: Top comment numbered “2”, next comment numbered “1”

    If I change fill_last_page = false, then everything works correctly:
    • Comments page 2: Top (newest) comment numbered “12”, with comment that appears below it numbered “11”.
    • Comments page 1: Comments numbered “10” through 1” from top to bottom.

    What am I doing wrong? This also happens with the unchanged Classic comments-paged.php template.

    Thank you!
    🙂 tanster

  49. Keyvan says:

    Tanster, you’re not doing anything wrong. I think you’ve identified a bug in the code. Expect a fix tomorrow. I don’t think I updated the numbering procedure when I introduced the fill_last_page feature. Thanks for flagging this up and including a detailed report.

  50. tanster says:

    Wow, thanks Kevan for the quick reply! I look forward to seeing your next version.

    🙂 tanster

5 Trackbacks

  1. […] Several plugins that might be useful if my post readership increases by several orders of magnitude: 1) WordPress Email Notification. If readership includes non-blogophiles who don’t know an RSS feed from a pig trough. http://watershedstudio.com/portfolio/software/wp-email-notification.ht ml 2) Subscribe to Comments. Allows readers to subscribe to the comments of a post by email, and manage their subscriptions. Ditto to previous for comments. http://www.scriptygoddess.com/archives/2004/06/03/wp-subscribe-to-comm ents/ 3) Paged Comments. Allows comments to be split across multiple pages. http://keyvan.net/code/paged-comments/ […]

  2. […] Paged Comments – very sueful if you have entries with hundreds or even thousands of comments. […]

  3. By Technical Assistance Request! - Pop Occulture on 12 January 2006 at 1:49 am

    […] Overall, it’s probably not the world’s hardest plugin to build, especially since you might be able to re-purpose some of the code from Keyvan’s paged comments plugin (which is sort of similar, but not quite). If there’s anybody who’d like to help a brother out with this, let me know. I don’t really have any money to throw at you, thanks to my upcoming move. But maybe we could trade a little bit of freelance design, or some kind of other arrangement. Or you could do it just cause you like me so much and want to help a brother out. That works too! Either way, drop me an email. Thanks! Read Similar Articles: […]

  4. By BloggingTom on 19 January 2006 at 3:28 pm

    WP Paged Comments Plugin

    Kommentare zu Postings können manchmal ganz schön unübersichtlich werden, und mit der Anzahl der Kommentare steigt auch die Ladezeit der Seite. Dies ist auch beim Post “Die Eypo AG schlägt zurück“, einem der beliebtesten Artikel auf d…

  5. […] Split things up – I’m sure you’ve all been to a post which has hundreds of comments and it takes forever to load. Paginate your comments once there’s too many to load on a single page. […]