Only allow the post author and admin to comment on a post

Depending on how your theme is set up, comments_open might be the filter you want. (in functions.php) add_filter( ‘comments_open’, ‘block_comments_for_others’, 10, 2 ); function block_comments_for_others( $is_open, $post_id ) { $is_open = false; $post_author_id = get_post_field( ‘post_author’, $post_id ); if ( get_current_user_id() == $post_author_id || current_user_can(‘administrator’) ) $is_open = true; return $is_open; } Or possibly something … Read more

How do I add class to an admin comment?

One way to add some custom class to a li tag if the comment was posted by an administrator is to replace line <li id=”comment-<?php comment_ID() ?>”> with <li <?php comment_class(); ?> id=”comment-<?php comment_ID() ?>”> This will add support for the default WP comments classes to your comments callback. Once you do that add in … Read more

comments_number not displaying

You need to change the code you’re using from <div class=”post-meta”> <p><?php the_date(); ?> | <?php the_tags(‘tags:’, ‘, ‘, ‘<br />’); ?> | <?php comments_number( $zero, $one, $more ); ?> comments</p> <?php comments_template(); ?> </div><!– end post-meta –> to <div class=”post-meta”> <p><?php the_date(); ?> | <?php the_tags(‘tags:’, ‘, ‘, ‘<br />’); ?> | <?php comments_number( … Read more

How do i hide all comments from logged out users

I would recommend looking for all occurrences of comments_template in your theme and wrapping them in a is_user_logged_in condiational. Example: <?php if (is_user_logged_in()) { comments_template(); } Alternatively, you can open up your theme’s comments.php (or the equivalent, it’s usually comments.php) and add something like this at the very top: <?php if (!is_user_logged_in()) { return; } … Read more