Keyvan Minoukadeh

WordPress Paged Comments Plugin

Filed under: General — Keyvan @ 12:24 am

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

Related Downloads

Installation for WordPress 2.5

If you’re upgrading from a previous version, skip these installation steps and read the upgrade steps.

  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

  • 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?

Donate

I work on this plugin in my spare time. If you find it useful, please consider donating to help me continue work on the plugin. (This plugin is, and will remain, free software, please only donate if you want to.)

This month I’ve received £0 ($0/€0) :(

Paid Support

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

709 Responses to “WordPress Paged Comments Plugin”

Pages: « 7116 15 14 13 12 [11] 10 9 8 7 61 » Show All

  • 110
    tanster

    Okay, paged comments are now functional on my site:

    http://www.officetally.com/?p=35#comments

    The theme being used is a modified version of the “Neat!” theme at http://www.aamukaste.org/wpthemes/?cat=3

    :) tanster

  • 109
    tanster

    That fixed it, Keyvan. Once again, thank you!

    :) tanster

  • 108
    Keyvan

    Hi Tanster,
    Sorry about that. Even the most basic maths still trips me up. :) I’ve corrected the code I posted earlier. Please try it and let me know if it works. (It’s looking quite ugly now—I’m sure there’s a very elegant mathematical solution out there somewhere!)

  • 107
    tanster

    Dayna: Thank you, that works like a charm!

    Keyvan: Thanks for the updated paged-comments.php; I’m not brave enough to use it, though! ;)

    Also, looks like I spoke too soon about the numbering working correctly in fill_last_page mode:

    Up to 19 comments, it works fine:
    - Page 2, 10 comments numbered “19″ through “10″
    - Page 1, 9 comments numbered “9″ through “1″

    Once I have 20 comments, this is what I see:
    - Page 2, 10 comments numbered “10″ through “1″ (should be “20″ through “11″)
    - Page 1, 10 comments numbered “0″ through “-9″ (should be “10″ through “1″)

    My settings:
    - all_posts = true;
    - per_page = 10;
    - ordering = ‘DESC’;
    - page_range = 5;
    - fancy_url = false;
    - show_all_option = true;
    - fill_last_page = true;

    Thanks!
    :) Jennie

  • 106
    Keyvan

    Dayna: If you’re using one of the bundled templates, you should have a call to this function within the comment loop:

    echo paged_comments_url('comment-'.get_comment_ID());

    The function returns the ‘permalink’ URL of a comment—it’s not perfect and I’m working on a better solution for a future release. The function will also take into consideration the current comment page. So, for example, when you load this page the last comment-page is active (at the moment page 11) but the page URL doesn’t contain the /comment-page-11/ path segement. So returning ‘#comment-1911′ is not enough as someone might link to, like in your example, http://www.keyvan.net/code/paged-comments/#comment-1911 (which is only valid while comment page 11 is being loaded by default). So paged_comments_url will (at least it does for me :)) return http://www.keyvan.net/code/paged-comments/comment-page-11/#comment-1911.

    Please check and let me know if paged_comments_url() is being used in your comments-paged.php template. If it’s not working right I’ll have to look into it some more.

    I mentioned above that I’m working on a better solution that will—if I implement it correctly :)—produce URLs with no reference to the comment page, somethine like: http://www.keyvan.net/code/paged-comments/comment-1911/.
    I’m hoping the code can then look at the paged-comments configuration to figure out, and redirect to, the correct comment page. (Not even sure if this is the ideal solution yet!) :)

    Tanster: I’m not too happy with the way it works at the moment (ie. having to maintain two comment templates). If you’re only after the comment numbers, you can do what Dayna suggested.

    The next version will always use the comments-paged.php template while the plugin is active within WordPress. (Deactivating will revert back to comments.php.) I’m actually using the development version on this site, which only uses comments-paged.php (so when you choose ’show all’ you’re still getting comments-paged.php). If you’re brave enough, you can load it and try it: paged-comments.php. You don’t need to make changes to your config file, but there is a new option available:

    // Show-all comment ordering
    // -------------------------
    // Determines how comments are ordered when loaded on a single page.
    // The default ascending ('ASC') order means comments will be ordered with
    // the earliest comment displayed first. 'DESC' reverses this order.
    // The ordering specified here is used in the following circumstances:
    // 1. When a user chooses the 'Show All' option to have all comments displayed at once.
    // 2. When the total number of comments has not exceeded the per_page value (ie. when
    //    they're few enough to fit on a single comment page).
    // In all other circumstances, the value specified in ordering is used.
    $paged_comments->show_all_ordering = 'ASC';

    Hope that helps.

  • 105
    Dayna

    tanster: I’m not sure if it’s the right way but this is how I do it

    add $commentcount=1;

    after $oddcomment = 'alt'; at the top of your comments.php

    and where you want the comment number to appear, use this

    echo $commentcount++;

    :)

  • 104
    tanster

    Hi Keyvan,

    I see that paged comments uses comments-paged.php as its template, and if I click “Show All” then regular comments use whatever comments.php file is in my current theme.

    I am using a theme, however, which doesn’t number the comments.

    My question is: how do I get my standard comments.php file to display numbers in the comments just like comments-paged.php? (Just like it works here at http://www.keyvan.net/code/paged-comments/)

    Thanks!
    :) tanster

  • 103
    Dayna

    Hi Keyvan,

    Is it all right for you to tell me how you achieve the permalinks to the comments with the paged comments?

    like

    http://www.keyvan.net/code/paged-comments/comment-page-11/#comment-1900

    instead of

    http://www.keyvan.net/code/paged-comments/#comment-1900

    Thanks :)

  • 102
    tanster

    Hi Keyvan,

    The new code works BEAUTIFULLY! I have it running in my sandbox; as soon as it’s public, I will let you know.

    Thanks again for being so responsive!

    :) tanster

  • 101
    Keyvan

    Tanster, here’s the fix for the comment number problem:

    Open paged-comments.php and find the following lines (should start from line 117) in the paged_comments_template() function:

    // comment numbering
    $comment_number = ...snipped...
    if ($paged_comments->ordering == 'DESC') {
        $comment_number += count($comments);
        $comment_delta = -1;
    } else {
        $comment_number += 1;
        $comment_delta = 1;
    }

    change to:

    // comment numbering
    $comment_number = ...snipped...
    if ($paged_comments->ordering == 'DESC') {
        $comment_mod = $comment_count % $paged_comments->pager->get_items_per_page();
        if ($paged_comments->fill_last_page && ($comment_mod != 0)) {
            $comment_number += $comment_mod;
        } else {
            $comment_number += count($comments);
        }
        $comment_delta = -1;
    } else {
        $comment_number += 1;
        $comment_delta = 1;
    }

    [Edited: 2006-02-17]

    That should do it. Let me know how you get on. I don’t have time to put out a new version yet, but the fix will be in the new version when it’s ready.

Pages: « 7116 15 14 13 12 [11] 10 9 8 7 61 » Show All

Leave a Reply