WordPress.org

Ready to get started?Download WordPress

Forums

Conditional php code not working (3 posts)

  1. Kathy_P
    Member
    Posted 7 years ago #

    I am using the Adsense Deluxe plugin to display Google Adsense ads. I want to display a particular ad only on my blog directory page. I am using this code but the ad isn't displaying:

    <?php if (is_page('garden-blog-directory')) {; ?>
    			<?php adsense_deluxe_ads('blog_directory_sidebar'); ?>
    			<?php } ?>

    Can anyone tell me what I am doing wrong? I figure I am missing punctuation somewhere.

  2. gfindlay
    Member
    Posted 7 years ago #

    Try this instead:

    <?php if (is_page('garden-blog-directory')) adsense_deluxe_ads('blog_directory_sidebar'); ?>

    Should work, all things being equal ;)

  3. Kathy_P
    Member
    Posted 7 years ago #

    Thanks for replying, gfindlay, but that didn't work.
    This code works at the beginning of the sidebar:

    <?php if (is_page('garden-blog-directory')) {; ?>
    <?php adsense_deluxe_ads('blog_directory_sidebar'); ?>
    <?php } else { ; ?>
    <?php adsense_deluxe_ads('Sidebar'); ?>
    <?php } ?>

    So I would think I'm just ending it incorrectly when I don't need the "else." According to the Adsense Deluxe plugin, "If you want to use the ads defined in Adsense-Deluxe within your WordPress templates, place the following code where you want the ads to appear:
    <?php adsense_deluxe_ads('Ad_Name'); ?>" I've tried comparing my problem code with code in my templates that does work, and I just can't see what I'm doing wrong. I haven't gone over Google's limit for number of ads on a page, so I don't think that's it either. Still scratching my head.

Topic Closed

This topic has been closed to new replies.

About this Topic