how to check if the post id has a new comment?
this is something goes on my mind
if (hasnewcomment(post->id)){
//echo something
}
any suggestion or help will do. using get the total comment or anything
please help
thankyou
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityThere is a WordPress hook comment_post to retrieve recently added comment and to pass comment id to get_comment you will get the post id.
add_action( 'comment_post', 'show_message_function', 10, 2 ); function show_message_function( $comment_ID, $comment_approved ) { $comment_array = get_comment($comment_ID ); $comment_post_id = $comment_array->comment_post_ID; }
As standard if you turn on manual comment moderation in Settings: Discussion the author of a post will be emailed whenever a comment to their post is made.
have_comments()
comes to mind. Although that may not check for "new" comments.