Forums

Associated Conditional Tags (6 posts)

  1. siounis
    Member
    Posted 2 years ago #

    So I there must be an association code to group Conditional Tags together.

    Here is what i got:

    <?php if ( is_page('1') ) { ?>
    **CODE X**
    <?php } ?>

    <?php if ( is_page('2') ) { ?>
    **CODE X**
    <?php } ?>

    <?php if ( is_page('3') ) { ?>
    **CODE X**
    <?php } ?>

    its pretty anoying to have to re write code x over and over.

    i tried using &&:

    <?php if ( is_page('1') && is_page('2') ) { ?>
    **CODE X**
    <?php } ?>

    but that didnt work.

    There must be an easier way. Anyone?

  2. BPartch
    Member
    Posted 2 years ago #

    Hello

    If you want all the pages to have the same content than you can just do:

    <?php if ( is_page() ) { ?>
    **CODE X**
    <?php } ?>

    That will affect all "Pages"

    If you want to do some pages one way and other pages different you can do:

    `<?php if ( is_page('1') || is_page('3') ) { ?>
    **CODE X**
    <?php } ?>`

    `<?php if ( is_page('2') || is_page('4') ) { ?>
    **CODE X**
    <?php } ?>`

    If you wanted to have the same content on a "Page" and single post you can do:

    `<?php if ( is_page() || is_single() ) { ?>
    **CODE X**
    <?php } ?>`

    Hope it helps. :)

  3. siounis
    Member
    Posted 2 years ago #

    my god thank you

    HIGHLY RECOMMEND they put this info in the conditional tages page.

    http://codex.wordpress.org/Conditional_Tags

  4. rudolf45
    Member
    Posted 2 years ago #

    HIGHLY RECOMMEND they put this info

    Q: They? Who is they?
    A: "they" is us - you and I and every WP user. Please, feel free to login to the Codex and add any additonal info you consider useful for your fellow users :)

  5. siounis
    Member
    Posted 2 years ago #

    no doubt? wow. yah ill do that. i think..i duno how though- lol like wikipedia?

  6. Chris_K
    Administrator
    Posted 2 years ago #

    EXACTLY like wikipedia

Topic Closed

This topic has been closed to new replies.

About this Topic