how to get value of coment_count (2 posts)

  1. bensmail
    Posted 3 years ago #

    I'm trying to modify a plugin that sends emails. I don't want it to send email when comment count = 0

    What PHP code do I need to pull that value from the wordpress database?

  2. bcworkz
    Posted 3 years ago #

    get_comments_number() returns the value from inside the loop. From outside the loop, you could do something like:

    $mypost= get_post($postID);
    $count = $mypost->comment_count;

Topic Closed

This topic has been closed to new replies.

About this Topic