Remove Comments Based on Categories in Genesis

You can remove and control the Comments section based on what Category a post is set to in Genesis by conditionally removing an action based on the category.

<?php //<~ don't add me in
add_action( 'genesis_before_entry', 'wpb_remove_comments_category' );
function wpb_remove_comments_category() {
if ( !in_category( 38 ) ) {//adjust your Category ID's in the conditional
remove_action( 'genesis_after_entry', 'genesis_get_comments_template' );

So in the code snippet above I want comments only on a certain category which has the id of 38, so the code says that is the post is not in the category of 38 then remove the comments template.


Leave a Comment

%d bloggers like this: