• Resolved orvn

    (@orvn)


    Hello,

    I’m trying to hide comments from a few categories on my WordPress 3.4.1 site.

    Using PHP to accomplish this:

    <?php if ( in_category( array( "services", "team", "testimonials") ) {
    .commentsection {display: none;}
    } ?>

    But I get an unexpected ‘{‘ error.

    What am I doing wrong?

    Site is combined-effort.com

Viewing 2 replies - 1 through 2 (of 2 total)
  • You’re missing a parenthese and closing php quotes (since you’re not echoing your CSS rule, you’re defining it inline :

    <?php if ( in_category( array( "services", "team", "testimonials") ) ) { ?>
    .commentsection {display: none;}
    <?php } ?>

    I’d also recommend that instead of setting a CSS rule based on if the page is in a certain category, place your check where the actual markup is being produced (such as in your comments.php or where the comment template file is being called in your template. Simply reverse the check (so !in_category(array()) ). This way you’re not generating the markup needlessly and hiding it with CSS.

    Thread Starter orvn

    (@orvn)

    Thanks, I implemented that. I really appreciate the added suggestion too, I’m new to this, but I do try to keep things efficient.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Having Trouble Removing Comments from a Particular Category’ is closed to new replies.