Support » Plugins and Hacks » Comments in Moderation – Front of blog?

  • Resolved glidem

    (@glidem)


    Is there any way to show how many comments are in moderation for admin etc on the front page of the blog (sidebar) rather than having to go to the admin page?

    Maybe a plugin or simple code I need to add?

Viewing 4 replies - 1 through 4 (of 4 total)
  • This from wp-admin/index.php

    $numcomments = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
    echo $numcomments;

    Great thanks…

    I am now using this code on my webpage:

    <?php
    $numcomments = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = ‘0’”);
    echo ‘(‘,$numcomments,’)’;
    ?>

    Anyway to make only admin see it though?

    An if statement similar to:

    if ( current_user_can('edit_users') )

    Thanks it works great now, very useful!

    In case anyone else is wondering, this is the code I used in the sidebar of the theme:

    <?php if ( current_user_can(‘edit_users’) ) { ?><?php
    $numcomments = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = ‘0’”);
    echo ‘<small>(‘,$numcomments,’)</small>’;
    ?><?php } ?>

    I actually put this in a <h2> tag next to the title text, so I could see clearly at the top how many comments were in moderation very quickly.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Comments in Moderation – Front of blog?’ is closed to new replies.