• greenflag

    (@greenflag)


    i want certain text to appear on ONLY 1st page of categories and tags.

    so on: mysite.com/tags/mytag/

    not on: mysite.com/tags/mytag/page/2/ etc….

    I have tried a few codes on codex but nothing seems to work. Any suggestions?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Michael

    (@alchymyth)

    <?php
    if( !is_paged() && ( is_category() || is_tag() ) ) :
    echo 'text';
    endif;
    ?>

    https://codex.www.ads-software.com/Conditional_Tags

    Thread Starter greenflag

    (@greenflag)

    thanks! i forgot to mention the text has html code in it and php things like <?php single_tag_title(); ?>. I used your suggestion like this and it worked!

    <?php if( !is_paged() && ( is_category() || is_tag() ) ) {?>

    my code

    <?php } ?>

    is the above statement correct?

    Thread Starter greenflag

    (@greenflag)

    lol thanks i edited post same time you answerd. thanks so much for the help!

    Michael

    (@alchymyth)

    looks alright to me ??

    Thread Starter greenflag

    (@greenflag)

    thanks again. i spent 10hrs yesterday trying figure this out!

    but my code is vailid then? i noticed you used a : (colon) in yours. Can I omit that?

    Michael

    (@alchymyth)

    there are two ways of coding an if statemant:

    <?php if( $this ) : ?>
    do something
    <?php endif; ?>

    and

    <?php if( $this ) { ?>
    do something
    <?php } ?>

    both are equally valid.

    Thread Starter greenflag

    (@greenflag)

    thanks again alycymtyh! good karma coming your way!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘text to appear on 1st pages of cats/tags’ is closed to new replies.