Support » Fixing WordPress » How do I remove comments from a particular category ?

  • Lawcom


    I would like to remove comments from 2 categories while still allowing comments in 2 other categories ..

    So this is not a global remove comments just specific to the 2 categories that do not require comments, so would like them removed..

    Anyone got an insight ?

    Thanks …

Viewing 7 replies - 1 through 7 (of 7 total)
  • kymac


    I can give you a query to identify the comments for a category. just replace ‘my_category_slug’ with your own category slug:

    SELECT *
    FROM wp_comments
    WHERE comment_post_ID
    IN (
    SELECT c.object_id
    FROM wp_terms a, wp_term_taxonomy b, wp_term_relationships c
    WHERE = 'my_category_slug'
    AND b.term_id = a.term_id
    AND b.taxonomy = 'category'
    AND c.term_taxonomy_id = b.term_taxonomy_id

    however, using this to delete comments is DANGEROUS! It will not reset the comment_count in the related posts, and I don’t know what effect this will have on the site.




    Thanks kymac ..

    It is a new site and as such no direct comments to delete, I just don’t want to make them available from the off ..

    In 2 specific categories which do not require commenting on ..



    You can do something more topical

    <?php if ( in_category( array( ‘cat1’, ‘cat2’) ) {
    //hide comments box
    .commentclass {display:none;}

    Look at the div class or id or whatever holds the comment box and use that for .commentclass



    mmmmmmmmm I was thinking there must be a simply WP solution that I was just too stupid or blind to see ?

    Surely WP didn’t expect every category produced would want to have comments made ? it seems like such a simple request to have.. This category, no comments..

    Is there not a plugin that I may have missed that does this ?



    I guess the first easy step is not to allow comments per post, a bit of a hassle but not too much, but then how would I remove the ‘Comments are closed.’ just on that category posts ?

    Jack Barham



    I presume that code needs to go in page.php, but where abouts in that page does the it need to go.

    I am trying to manually disable comments from certain categories as well!

    Many thanks – Jack

    Hi, I’m also trying to turn off comments in some category pages.
    I would like to know how to do this, I also can’t seem to get it to work atm, what .php file should we add this, I’m not very good at .php you see 🙂


Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How do I remove comments from a particular category ?’ is closed to new replies.