Support » Themes and Templates » Show Comment Count (span) only if in specific categories

  • Resolved keysuuh

    (@keysuuh)


    I ended up with this line of code//
    <span class="comments"><a href="<?php comments_link(); ?>"><?php if (in_category('14') || in_category('15') || in_category('1')) comments_number( '0', '1', '%' ); ?><span class="link-spanner"></span></a></span>

    What I am aiming for is to remove the whole span if post is not in a specific category…
    But that code above only removes the actual number of comments…

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    moderator

    Try it with this:

    <?php if (in_category('14') || in_category('15') || in_category('1')) : ?>
    <span class="comments"><a href="<?php comments_link(); ?>"><?php comments_number( '0', '1', '%' ); ?><span class="link-spanner"></span></a></span>
    <?php endif; ?>

    Fabulous 🙂 Thank you very much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show Comment Count (span) only if in specific categories’ is closed to new replies.