I'm trying to edit my comments.php so that I can conditionally display //do something if the comment author is also the post author. I have no idea what I'm doing but I've managed to throw this piece of garbage together as a start (what a joke)...

<?php if ( get_comment_author(global $wp_get_current_commenter();   wp_get_current_commenter() && $wp_get_current_commenter()->ID && == $post->post_author)) { ?>
// do something
<?php } ?>

I've read this link but it's no more clear to me.

1 Answer 1

<?php if ( $post = get_post($post_id) ) : ?>
<?php if ( $comment->user_id === $post->post_author ) :?>
//do something
<?php endif;?>
<?php endif;?>


global $post;
if( $comment->user_id === $post->post_author ) {
// do something

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.