Paged Comments FAQ

Most of these questions are taken from the comments posted on the Paged Comments plugin page. If you have a question that is not answered here, please post it on the plugin’s page.

Note: these answers apply to the latest version of the Paged Comments plugin running on WordPress 1.5 or 2.x. If a solution does not work for you, please make sure you’re running the latest version of the plugin.

Q: Can I use the plugin with older versions of WordPress?

Paged Comments 2.6.4 was the last release to support WordPress versions 1.5 up to 2.5. You can download version 2.6.4 or one of the earlier versions from the WordPress plugin directory.

Q: Why do I keep getting fatal errors to do with eval()’d code?

Note: This problem cropped up frequently with earlier version of the plugin. Versions starting from 2.6.4 should work fine for most people experiencing this problem.

If you’re using version 2.6.4 or later, and you’re still experiencing this problem, you can avoid the eval statement by explicitly calling the paged_comments_template() function instead of comments_template(). To do this, open the templates in your active theme and look for calls to comments_template()—these will most likely be in single.php and page.php. Replace the call to comments_template() with this:

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

The plugin looks for paged_comments_template() in your template file, if it’s found we assume you’ve modified your template for use with the plugin, and so you avoid the eval() call. If it’s not found, the plugin will replace calls to comments_template with paged_comments_template and eval the resulting code.

I would still like to hear from anyone experiencing eval() problems since 2.6.4—I don’t think anyone should be experiencing this with the latest release.

Q: Is there a way to determine if a comment page has been requested or not?

Yes. When a user clicks on a comment page number, the requested page is stored in PHP’s predefined $_GET variable associated with the ‘cp’ key. It’s enough to check for the existence of this key to know if a comment page has been requested or not.

For example: <?php if (isset($_GET['cp'])) echo 'comment page requested'; ?>

Bear in mind that a comment page is usually active by default when a comment-laden post is loaded. The method above only tests for explicit comment page requests.

Also, the value stored at $_GET['cp'] is not reliable to use—a user could request comment page 999 whether it exists or not!

Q: Can I hide the post body when users navigate to a comment page?

Yes. Edit single.php and/or page.php, qualifying the call to the_content() with an if statement. For example:

<?php the_content('<p>Read the rest of this entry</p>'); ?>

becomes

<?php if (!isset($_GET['cp'])) {
    the_content('<p>Read the rest of this entry </p>');
} ?>

If you’d like to guide visitors back to the full content, you can include an else statement with a link to the main article:

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

Q: Can I hide the postmetadata paragraph when users navigate to a comment page?

Yes. Open single.php and, using the conditional statement described earlier, replace this chunk of code:

<p class="postmetadata alt">
    <small>This entry was posted...</small>
</p>

with

<?php if (!isset($_GET['cp'])): ?>
    <p class="postmetadata alt">
        <small>This entry was posted...</small>
    </p>
<?php endif; ?>

Q: Can I hide the comment form when users navigate to a comment page?

Yes. The procedure is similar to that of hiding the post body. Open comments-paged.php and wrap the conditional statements around the <form> element. For example, replace this chunk of code:

<form action="<?php 
  echo get_option('siteurl'); 
  ?>/wp-comments-post.php" method="post" id="commentform">
...
</form>

with

<?php if (!isset($_GET['cp'])): /* show form */ ?>
<form action="<?php 
  echo get_option('siteurl'); 
  ?>/wp-comments-post.php" method="post" id="commentform">
...
</form>
<?php else: /* hide form */ ?>
<p>You are browsing comments, <a href="<?php 
  echo get_permalink(); ?>">post a comment here</a>.</p>
<?php endif; ?>