Troubleshooting
Troubleshooting
If you encounter issues where comments are not being restricted as expected, or if authorized users cannot view them, please review the following common solutions.
Comments are still visible to the public
The most common cause for comments remaining public after activation is caching. Because this plugin modifies the output of the comment query based on the logged-in user, static versions of the page may still show old data.
- Clear Page Cache: If you use a caching plugin (e.g., WP Rocket, W3 Total Cache, LiteSpeed Cache), clear all caches.
- Clear Server/CDN Cache: If your host uses Nginx FastCGI caching, Varnish, or a CDN like Cloudflare, purge the cache for the specific post or the entire site.
- Test in Incognito: Always verify the visibility by visiting the post in a private/incognito browser window while logged out.
Theme Compatibility Issues
The plugin hooks into standard WordPress comment filters (comments_clauses or the_comments). If your theme uses a custom database query or a non-standard method to display comments, the plugin may be bypassed.
- Test with a Default Theme: Temporarily switch to a default WordPress theme (like Twenty Twenty-Four). If the comments become private, your previous theme is using a custom implementation that ignores standard WordPress hooks.
- Check
comments_template(): Ensure your theme'ssingle.phporcomments.phpfile uses the standardcomments_template()function to render the comment section.
Comment Count Discrepancies
In some configurations, the total comment count displayed (e.g., "5 Comments") might include private comments even if the comments themselves are hidden. This happens because the count is often stored as a meta value in the wp_posts table and is not always filtered dynamically.
To fix this, you may need to ensure your theme uses get_comments_number() which is typically handled by WordPress, but some themes may require a manual refresh of the count.
Post Authors cannot see comments
The plugin grants visibility to the Post Author. If a user has the "Editor" role but is not the specific author of that post, they will not see the private comments unless they also have the "Administrator" role.
- Verify Ownership: Check the "Author" field in the WordPress Post Editor to ensure it matches the user attempting to view the comments.
- Role Check: Ensure the user has the
manage_optionscapability (Administrators) or is the explicitpost_author.
Plugin Conflicts
If you are using other comment-related plugins (such as "wpDiscuz" or custom AJAX comment loaders), they may override the visibility logic.
- Deactivate and Re-test: Deactivate other comment plugins one by one to identify the conflict.
- Priority: If you are a developer and need to adjust the execution order, the plugin filters the comment query. Ensure no other plugin is unhooking these filters.
Debug Mode
If the issue persists, enable WordPress debugging to check for underlying errors. Add the following to your wp-config.php file:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
Check the /wp-content/debug.log file for any errors related to the Private Comments plugin or database query failures.