WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Show Comment Count (span) only if in specific categories (3 posts)

  1. keysuuh
    Member
    Posted 1 year ago #

    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...

  2. keesiemeijer
    moderator
    Posted 1 year ago #

    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; ?>
  3. keysuuh
    Member
    Posted 1 year ago #

    Fabulous :) Thank you very much!

Topic Closed

This topic has been closed to new replies.

About this Topic