{"id":2194733,"date":"2011-07-19T00:03:26","date_gmt":"2011-07-19T00:03:26","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/remove-comments-in-specific-categories\/"},"modified":"2016-08-20T01:32:49","modified_gmt":"2016-08-20T01:32:49","slug":"remove-comments-in-specific-categories","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/remove-comments-in-specific-categories\/","title":{"rendered":"Remove comments in specific categories"},"content":{"rendered":"<p>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 &#8216;blog&#8217;.<\/p>\n<p>Here is what I have. The file &#8216;no-comments.php&#8217; is completely empty;<\/p>\n<pre><code>function remove_comments( $file ) {\n\tif ( !in_category(&#039;blog&#039;) )\n\t\t$file = STYLESHEETPATH . &#039;\/no-comments.php&#039;;\n\treturn $file;\n}\nadd_filter( &#039;comments_template&#039;, &#039;remove_comments&#039;);<\/code><\/pre>\n<p>It works except that when viewing the posts in the &#8216;blog&#8217; category, the link to view comments doesn&#8217;t work anymore. Does anyone have any ideas as to what the problem could be?<\/p>\n","protected":false},"template":"","class_list":["post-2194733","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/2194733","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/2194733\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=2194733"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}