This is a strange one. I host a website that is primarily for children. All posts are moderated. Users are required to enter a user name and location (State), but are not required to be registered and logged in to make a comment. Some users have started using a common user name, allowing them to see one another's posts while the posts are awaiting moderation. This allows them to use the posts awaiting moderation like an unmoderated chat room, until the moderator gets to the comments.

I would like to filter the comments on the posts so that only approved comments are shown, regardless of whether the user just entered a comment that is awaiting moderation.

I have looked in the wp-includes/comments.php, and in the wp-includes/post.php but haven't been able to find where to limit the comments that are seen on the posts.

Can anyone direct me further?

  • +1 for ingenious children. The place where you'll need to edit which comments get displayed would be in your theme's comments.php. Please post your theme name (or the code from that file if it's custom). Oct 18, 2012 at 18:04
  • @stealthyninja - Thanks for your help. The Theme is custom. I am not sure from which Theme is was originally modified. The code is below:
    – VWTom
    Oct 18, 2012 at 18:32
  • Having issues putting the code from the comments.php up. I will see what I can find based upon your answer below. Thank you for your help.
    – VWTom
    Oct 18, 2012 at 18:51
  • You could put it on pastebin. Oct 18, 2012 at 18:53

2 Answers 2


Check in your theme's comments.php for the wp_list_comments() function. In the Twenty Eleven theme, for example, uses a custom callback function which is in the functions.php file and outputs the template for comments.

Within this comments template, you can then use wp_get_comment_status() and only display a comment if it was approved. Example from the Codex:

$status = wp_get_comment_status( $comment_id );

if ( $status == "approved" ) {
    // the rest of the comment loop
  • Thanks @stealthyninja! You pointed me in the correct direction. I found out my Theme was a modification of the Kubrick Theme, so this is what I did:
    – VWTom
    Oct 18, 2012 at 21:49
  • 2
    <?php if ($comment->comment_approved == '1') : ?> // the rest of the comment loop
    – VWTom
    Oct 18, 2012 at 21:52

In wp-includes/admin-bar.php, add a "return;" statement at the start of wp_admin_bar_comments_menu so it looks like this:

function wp_admin_bar_comments_menu( $wp_admin_bar ) {
        return; /* Added by don smith */;
        if ( !current_user_can('edit_posts') )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.