WordPress.org

Ready to get started?Download WordPress

Forums

php quandary in sidebar ($single post?) (3 posts)

  1. MrFlora
    Member
    Posted 8 years ago #

    I'm trying to place an ad unit in my sidebar that will not display when in single post view. I've tried setting up something like this:

    <?php
    if ($single) { ?>
    <?php } else { ?>
    (ad unit code)
    <?php } ?>

    I was thinking that when it was in single post view, nothing would show, and when it was in any other view, the ad would show.

    Its not working though. I'm starting to think that the problem is that whatever signal tells the system that you're in single post view is closed before the sidebar is even placed so the if/else stuff isn't even being activated.

    What do I need to add to my sideabar for it to be able to determine if I'm in single view or not?

    If you haven't guessed I'm a php noob.

    you can check out my blog at http://www.goculver.com

    Thanks!

  2. Kafkaesqui

    Posted 8 years ago #

    Try:

    <?php if (!is_single()) { ?>
    (ad unit code)
    <?php } ?>

  3. MrFlora
    Member
    Posted 8 years ago #

    thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic