• I would like some help using conditional tags. For example, I’m trying to use different text in the sidebar for my pages. A, B, and C will have the same text in the sidebar, D will have it’s own text, and I would like a catch all for all additional pages i.e E, F, etc.

    This code is working, but I don’t know what to use for the catch all.

    <?php if (is_page(array(A,B,C))) { ?>
    <p>Page A, B, and C content</p>
    <?php } ?>

    <?php if (is_page(D)) { ?>
    <p>Page D content</p>
    <?php } ?>

    Please advise, thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • <?php if (!is_page(array(A,B,C,D))) { ?>
    <p>catch all</p>

    Thread Starter ClipThis

    (@clipthis)

    Seems to work (of course added the <?php } ?> )

    Thank you!

    Thread Starter ClipThis

    (@clipthis)

    A side note…

    The “catch all” text appeared on my post and category pages. I did have additional conditional tags for posts and category pages, so I tried moving the

    <?php if (!is_page(array(A,B,C,D))) { ?>
    <p>catch all</p>
    <?php } ?>

    to the end of my side bar, after all the other tags, and solved my problem. The “catch all” text is now removed from my posts and category pages.

    Thanks again!

    Thread Starter ClipThis

    (@clipthis)

    Well, ran into another issue. You’ll see below, post 21 and 29 have different content in their sidebars. I then created the “catch all” for all other single posts. When I visit post 21 and 29, they have their respected sidebar content. All other posts have the “catch all”. Works good. But when I visit a page, or a category page, it pulls their respected sidebar content plus the “catch all” content. How do we fix that?

    Here’s my code:

    <!– sidebar if pages… –>
    <?php if (is_page(array(history,education))) { ?>
    <p>Content A</p>
    <?php } ?>

    <?php if (is_page(contact)) { ?>
    <p>Content B</p>
    <?php } ?>

    <!– sidebar if category… –>
    <?php if (is_category()) { ?>
    <p>Content C</p>
    <?php } ?>

    <!– sidebar if search –>
    <?php if (is_search()) { ?>
    <p>Content D</p>
    <?php } ?>

    <!– sidebar if single –>
    <?php if (is_single(21)) { ?>
    <p>Content E</p>
    <?php } ?>

    <?php if (is_single(29)) { ?>
    <p>Content F</p>
    <?php } ?>

    <?php if (!is_single(array(21,29))) { ?>
    <p>catch all for single posts</p>
    <?php } ?>

    Thank you for the help!

    Thread Starter ClipThis

    (@clipthis)

    Any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Using Conditional tags in Sidebar’ is closed to new replies.