WordPress Paged Comments 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
- Version 2.7.1 (2008-07-14) (zip file) Release Notes
- View code at the WP Plugin Repository
- Work in progress: Ajax-style Paged Comments (no download yet - AJAX support coming in version 3)
Related Downloads
Installation for WordPress 2.5
If you’re upgrading from a previous version, skip these installation steps and read the upgrade steps.
- Download and extract plugin files to a folder locally.
- Read through and edit paged-comments-config-sample.php to configure, then save the file as paged-comments-config.php.
- Upload the whole paged-comments directory to /wp-content/plugins/. The plugin files should now be in /wp-content/plugins/paged-comments/.
- 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:
- White Town guestbook
- Thank You Stephen Colbert (over 60,000 comments!)
- Playstation
- eBay
- Mashable
- TorrentFreak
Questions?
- Read the FAQ and if it’s not answered…
- Leave a comment or email: keyvan (at) k1m.com
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.)
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
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
That fixed it, Keyvan. Once again, thank you!
Hi Tanster,
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!)
Sorry about that. Even the most basic maths still trips me up.
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
Dayna: If you’re using one of the bundled templates, you should have a call to this function within the comment loop:
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:
Hope that helps.
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.phpand where you want the comment number to appear, use this
echo $commentcount++;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
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
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, 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:
change to:
[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.