Title: Conditional Not Working
Last modified: August 18, 2016

---

# Conditional Not Working

 *  [Lindsey](https://wordpress.org/support/users/lalindsey/)
 * (@lalindsey)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/conditional-not-working/)
 * Not sure what’s going on here. We want to have this google adsense code show 
   on all pages but the homepage. So to test I put this:
 * `<?php if (is_home()) {
    echo 'nothing'; } else { echo '<script type="text/javascript"
   ><!-- google_ad_client = "removed"; google_ad_width = 160; google_ad_height =
   600; google_ad_format = "160x600_as"; google_ad_type = "text_image"; google_ad_channel
   =""; google_color_border = "000000"; google_color_bg = "FFFFFF"; google_color_link
   = "FFFF66"; google_color_text ="000000"; google_color_url = "CAF99B"; //--></
   script> <script type="text/javascript" src="http://pagead2.googlesyndication.
   com/pagead/show_ads.js"> </script>'; } ?>
 * I’ve used conditionals before with no issues… and I am pretty sure it’s right,
   but no matter what it’s showing up across the whole site. I even tried changing
   is_home() to is_single() to see if it would display the “nothing” there, but 
   no luck. I also tried instead of wrapping my echoes in “” regular quotes to use
   the single quotes (”) and escaping the google adsnese quotes with \ , but still
   shows across site….
 * Thanks,
    Lindsey

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

 *  [phuckd](https://wordpress.org/support/users/phuckd/)
 * (@phuckd)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/conditional-not-working/#post-464429)
 * try it like this :
 * `<?php
    if (is_home()){ echo ("hello world"); } else { echo ("<script type="text/
   javascript"><!-- google_ad_client = "removed"; google_ad_width = 160; google_ad_height
   = 600; google_ad_format = "160x600_as"; google_ad_type = "text_image"; google_ad_channel
   =""; google_color_border = "000000"; google_color_bg = "FFFFFF"; google_color_link
   = "FFFF66"; google_color_text ="000000"; google_color_url = "CAF99B"; //--></
   script> <script type="text/javascript" src="http://pagead2.googlesyndication.
   com/pagead/show_ads.js"> </script>"); } >?
 * see if that brings it back it may need the single quotes – ill have to test it
   later if i remember, but that should be ok, just addind the (‘s
 *  [viper007bond](https://wordpress.org/support/users/viper007bond/)
 * (@viper007bond)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/conditional-not-working/#post-464432)
 * phuckd: Your PHP won’t work. Single quotes need to be used, or you need to escape
   every single double quote within that Javascript in order to avoid ending the
   echo. Not to mention, there is no need for parenthesis when using echo.
 * See: [http://www.php.net/manual/en/function.echo.php](http://www.php.net/manual/en/function.echo.php)
 * lalindsey: There is nothing wrong with your PHP. I am not sure why it is not 
   working. Perhaps you could paste the entire file at [Pastecode.com](http://pastecode.com/)
   for us.
 *  [phuckd](https://wordpress.org/support/users/phuckd/)
 * (@phuckd)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/conditional-not-working/#post-464444)
 * >>phuckd: Your PHP won’t work
 * hence why i said it may need the single quotes.
 *  [viper007bond](https://wordpress.org/support/users/viper007bond/)
 * (@viper007bond)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/conditional-not-working/#post-464446)
 * Well parenthesis still aren’t needed and it’s actually encouraged to not use 
   them. 😉
 *  Thread Starter [Lindsey](https://wordpress.org/support/users/lalindsey/)
 * (@lalindsey)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/conditional-not-working/#post-464538)
 * Hey guys,
 * Thanks so much. I’ve pasted the entire sidebar code here: [http://pastecode.com/6338](http://pastecode.com/6338)
 * If you want to see the entire site, it’s here: [http://viralvoice.net](http://viralvoice.net)
 * It’s the adsense code in the right sidebar we want to not be shown on the homepage,
   but shown on every other.
 * I don’t know if this matters or not, but it may — I’m using different code for
   the main index posts to get one/two posts for each of those categories to show
   under the right headings. I’ve pasted that code here: [http://pastecode.com/6339](http://pastecode.com/6339)
 * Thanks again for any and all help,
    Lindsey

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

The topic ‘Conditional Not Working’ is closed to new replies.

## Tags

 * [conditionals](https://wordpress.org/support/topic-tag/conditionals/)
 * [is_home](https://wordpress.org/support/topic-tag/is_home/)
 * [is_single](https://wordpress.org/support/topic-tag/is_single/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [Lindsey](https://wordpress.org/support/users/lalindsey/)
 * Last activity: [19 years, 7 months ago](https://wordpress.org/support/topic/conditional-not-working/#post-464538)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
