Support » Fixing WordPress » Hide recent comments if none exist

  • Am I crazy or just blind? This seems like it would be a really simple thing to do without modifying the core files or installing a plug-in, yet I can’t find a single thing on the interwebs that would help me figure out how to do this.

    Is there something I can put into functions.php?

Viewing 3 replies - 1 through 3 (of 3 total)
  • I think if you just use this:

    <?php comments_popup_link(’0 Comments’, ’1 Comment’, ‘% Comments ‘); ?>

    and remove the message text “0 comments” ?

    that one i get. it’s the recent comments widget in the sidebar i’m asking about. where you can choose how many of the comments to display with an excerpt of the comment that then goes to that post comment

    if you can get the css for your recent comments widget you might be able to do something like this as a function, but I’m weak with code and this is not tested, but this is the general idea:

    function hide_if_no_comment() { 
    $comment_count = get_comment_count($post->ID); ?>
    if ($comment_count < 1) : ?>
    echo '<style type="text/css"> 
    (css for recent comments widget)

    I’m trying to say, “if comments are less than one, dont display the recent comments widget”

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide recent comments if none exist’ is closed to new replies.