WordPress.org

Ready to get started?Download WordPress

Forums

How To Display Code On A Specific Category Page (6 posts)

  1. jockpost
    Member
    Posted 4 years ago #

    I have a customer who would like to display an ad on the following page:

    http://jockpost.com/category/nba/page/13/

    How can I tell WordPress (preferably using PHP code, not a plugin) to display the ad code only on that exact URL/page, in that category?

    Thanks in advance for your help!

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    <?php if (is_page('13') && in_category('nba')) {?>
    
     Insert your code...
    
    <?php }?>
  3. jockpost
    Member
    Posted 4 years ago #

    Sorry, but the code above didn't work for me.

    I'm very close...

    The following code below is almost working. The problem is I can't seem to get it to be the exact page.

    <?php if ( $paged > 12 && is_category('nba')) { ?>
    <p>Test</p>
    <?php } ?>

    This shows the code on all pages above Page 12. If I change the greater-than symbol to an equals sign, it stops working. How can I have it show up on one specific page in an archive (category)?

  4. jockpost
    Member
    Posted 4 years ago #

    Believe it or not, this worked:

    <?php if ( $paged > 12 && is_category('nba') && $paged < 14 ) { ?>
    Text
    <?php } ?>

    Seems a little hokey to me...

  5. Mark / t31os
    Moderator
    Posted 4 years ago #

    More than 12 and less than 14, lol, why not just check if it's a value of 13?

    <?php if( 13 == $paged && is_category('nba') ) : ?>
    Text
    <?php endif; ?>
  6. gazouteast
    Member
    Posted 4 years ago #

    LOL Mark beat me to it, but I wanted to keep the "hokey-ness" and bracket the options

    <?php if((( 13 == $paged || ($paged == 13 )) && (is_category('nba'))): ?>
    Text
    <?php endif; ?>

    ;)

Topic Closed

This topic has been closed to new replies.

About this Topic