WordPress.org

Forums

Conditional tags inside the Sidebar and Ad Rotator Widget (2 posts)

  1. pshero
    Member
    Posted 6 years ago #

    Hey gang, I'm hoping somebody can help me with a little issue I'm having. I'm using Kpumuk's Ad Rotator plugin. What I'd like to do is write a conditional phrase inside the Ad Rotator widget to tell it which ads to rotate on which pages. Something like this:

    <?php if (is_page('Contact')) { ?>
    This would be the Ad I'd display on the contact Page
    <?php } elseif (is_page('Quote Request')) { ?>
    This would be the Ad displayed on the Quote Request page
    <?php } else {} ?>

    For some reason my sidebar doesn't recognize the is_page, is_category, or any other page identifier and I'm not sure why.

    If I run a test like '<php if (is_page('Contact')) echo ('This is the contact page'); ?>' it puts that text in the sidebar of every page, obviously not recognizing that the other pages aren't the Contact page. Is there some reason the sidebar doesn't recognize what page I'm on?

    Any help would be GREATLY appreciated

  2. pshero
    Member
    Posted 6 years ago #

    I figured out that my sidebar (which is the 2nd sidebar in the theme) wasn't able to take advantage of the is_page / is_category conditionals because I've got new queries happening in my first sidebar that are apparently overwriting the query that collects the post.

    So I moved my secondary sidebar up so it's called before the primary sidebar and how I can use the conditionals directly in the sidebar.php file and they work, but if I type the condition into the Ad Rotator widget in the Widgets panel it doesn't perform the PHP task, it just gets ignored.

    Any ideas?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.