Title: Conditional php code not working
Last modified: August 18, 2016

---

# Conditional php code not working

 *  [Kathy_P](https://wordpress.org/support/users/kathy_p/)
 * (@kathy_p)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/conditional-php-code-not-working/)
 * 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.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [gfindlay](https://wordpress.org/support/users/gfindlay/)
 * (@gfindlay)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/conditional-php-code-not-working/#post-586081)
 * Try this instead:
 * <?php if (is_page(‘garden-blog-directory’)) adsense_deluxe_ads(‘blog_directory_sidebar’);?
   >
 * Should work, all things being equal 😉
 *  Thread Starter [Kathy_P](https://wordpress.org/support/users/kathy_p/)
 * (@kathy_p)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/conditional-php-code-not-working/#post-586175)
 * 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.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Conditional php code not working’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Kathy_P](https://wordpress.org/support/users/kathy_p/)
 * Last activity: [18 years, 11 months ago](https://wordpress.org/support/topic/conditional-php-code-not-working/#post-586175)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
