Support » Plugins » How do you check if a post has comments ?

  • Hi guys,

    Is there a way to check if a post/page has comments already ? I would like to include my javascript only on posts/pages who have comments already.

    Thanks,

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plucko

    (@plucko)

    Yeah I’m wondering that too. Does anyone know how to do this?

    If you’re in the Loop, you can use use the built-in function, get_comments_number()

    so,

    <?php
    if (get_comments_number()==0) {
        // post has no comments
    } else {
        // post has comments
    }
    ?>

    thanks =)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do you check if a post has comments ?’ is closed to new replies.