WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [closed] Hide the comments form in a specific category? (2 posts)

  1. jbickers
    Member
    Posted 5 years ago #

    Looking for the easiest/most goof-proof/most upgrade-friendly way to hide the comment functionality on all posts in a specific category ... thanks in advance!

  2. Mark / t31os
    Moderator
    Posted 5 years ago #

    <?php
    if(!in_category('5')) {
    // If not in category with the ID 5...
       YOUR COMMENTS CODE
    }
    ?>

    NOTE: You might need to use is_category as appose to in_category..

    Or create a file called category-5.php and exclude the comments code (as in, just leave it out)...

    In both cases change the 5 to the ID of the category...

    Rel:
    http://codex.wordpress.org/Template_Hierarchy
    http://codex.wordpress.org/Conditional_Tags

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags