Forums

[resolved] Can an If Statement Work in a Sidebar?? (3 posts)

  1. andymacdonalduk
    Member
    Posted 1 year ago #

    Hey Guys,

    Could anybody tell me if an if statement will work in a sidebar please? Basically, I want to include an adsense ad in my sidebar on all pages except single.php.

    Is there a way to omit the advert from the sidebar when the single.php page is being used, without creating a whole new sidebar?

    Thanks for your time.
    Andrew

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    if you edit it directly into sidebar.php:

    <?php
    wp_reset_query(); // just in case a custom query had distorted the original query_string
    if(!is_single()) { ?>
    /*put your adsense code here*/
    <?php } ?>
  3. andymacdonalduk
    Member
    Posted 1 year ago #

    Ahh, that worked a treat. Thank you very much. Your advice is appreciated. :-)

Topic Closed

This topic has been closed to new replies.

About this Topic