logo

Personal tools
Vasudeva Archive 2007 11 07 Having paged comments in Wordpress
Navigation
About our blog
/images/easyblog_50.jpg
Our issue tracker
/images/jira_button_jpg

Atlassian supports our efforts by contributing their bug tracking and issue tracking application, JIRA. There are a few very nice Zope and Plone based ticketing systems, but we have still to find a better bug tracking and issue tracking application than JIRA, developed in any platform.

 

Having paged comments in Wordpress

| Posted by Shane Magee | Permanent Link | Blogging
Average Rating: 1 2 3 4 5 ( 0 votes)
Click to change your rating: (not rated)
  worthless bad average good great

If you have a very popular blog it might be worth dividing your comments into pages for easier viewing. Fortunately there is a Wordpress plugin called Paged Comments to do just that, thanks to Keyvan Minoukadeh. However it needs a bit of tweaking to work on your site.

Installing and configuring

  • Download and extract plugin files to a folder locally.
  • You can change the number of posts per page and some other useful settings by editing the paged-comments-config-sample.php file (its all fairly well explained in the file), then save the file as paged-comments-config.php.
  • Upload the whole paged-comments directory to /wp-content/plugins/ and enable the plugin through the WordPress admin interface.

Template hacking (yuck)

  • We need to include the comment 'pager' in our template. If you are using a common theme, it might already be taken care of: just go to /wp-content/plugins/paged-comments/themes, open your theme folder, and then copy the comments-paged.php file there into your theme folder at /wp-content/themes
  • If you are not using any of the themes listed in /wp-content/plugins/paged-comments/themes then go to your theme and copy the comments.php file to comments-paged.php

We will then modify the comments-paged.php as follows:

In the code at the start

<?php // Do not delete these lines
    if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
        die ('Please do not load this page directly. Thanks!');

change comments.php to comments-paged.php

To add the pager, place this code

  <!-- 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 -->

before the <ol class="commentlist"> line and again after the </ol> marking the end of it

If you want to make comment number visible on the blog, add this line of code

<div class="comment-number"><?php echo $comment_number; $comment_number += $comment_delta;?></div>

You can add it anywhere between <?php foreach ($comments as $comment) : ?> and <?php endforeach; / end for each comment / ?>, but the best place is probably before the author name (<cite><?php comment_author_link() ?></cite>). In practice, this hasn't worked too well for me, so use with caution.

Comments

There are no comments yet.