WordPress.org

Ready to get started?Download WordPress

Forums

how to get value of coment_count (2 posts)

  1. bensmail
    Member
    Posted 1 year 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
    Member
    Posted 1 year 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