- Can I use the plugin with older versions of WordPress?
- Why do I keep getting fatal errors to do with eval()’d code?
- Is there a way to determine if a comment page has been requested or not?
- Can I hide the post body when users navigate to a comment page?
- Can I hide the postmetadata paragraph when users navigate to a comment page?
- Can I hide the comment form when users navigate to a comment page?
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:
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:
Read the rest of this entry'); ?>
becomes
if (!isset($_GET['cp'])) {
the_content('Read the rest of this entry
');
} ?>
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:
Read the rest of this entry'); } else { echo '
You are browsing comments',
'read full entry here.';
} ?>
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:
with
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