• Resolved Chris

    (@chips)


    I am trying to write a function in my child theme that will remove the comments on all pages and posts apart from posts in a category called ‘blog’.

    Here is what I have. The file ‘no-comments.php’ is completely empty;

    function remove_comments( $file ) {
    	if ( !in_category('blog') )
    		$file = STYLESHEETPATH . '/no-comments.php';
    	return $file;
    }
    add_filter( 'comments_template', 'remove_comments');

    It works except that when viewing the posts in the ‘blog’ category, the link to view comments doesn’t work anymore. Does anyone have any ideas as to what the problem could be?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Remove comments in specific categories’ is closed to new replies.