Title: adding adsense to sidebar loop..?
Last modified: August 19, 2016

---

# adding adsense to sidebar loop..?

 *  [ivyology](https://wordpress.org/support/users/ivyology/)
 * (@ivyology)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/adding-adsense-to-sidebar-loop/)
 * Hi guys,
 * I’m trying to add a x600 adsense banner in my sidebar which will only be visable
   when the reader clicks on a single post.
 * I’ve read some tutorials which say to add the adsense code in the single.php 
   file (which I don’t have, so I’m using my index.php file) like this;
 * <?php
    if (is_single()) { echo ‘ **Your adsense code goes here** ‘;} ?>
 * When I do this the ads appear under the posts and not in the sidebar. Where abouts
   do you think I should put my code? Any help is much appreciated!
 * Here is my entire index.php code incase it helps;
 * [useless long code moderated]

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

 *  Thread Starter [ivyology](https://wordpress.org/support/users/ivyology/)
 * (@ivyology)
 * [18 years ago](https://wordpress.org/support/topic/adding-adsense-to-sidebar-loop/#post-764360)
 * I got a new theme so problem solved (kinda)
 *  [haochi](https://wordpress.org/support/users/haochi/)
 * (@haochi)
 * [18 years ago](https://wordpress.org/support/topic/adding-adsense-to-sidebar-loop/#post-764361)
 * Well, you are supposed to put that piece of code in sidebar.php (most likely 
   anyway). And instead of echo-ing the code out, you should do something like this:
 *     ```
       <?php
       if(is_single()){
       ?>
       AdSense code here
       <?php } ?>
       ```
   
 * It saves a lot of hassle.

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

The topic ‘adding adsense to sidebar loop..?’ is closed to new replies.

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [sidebar](https://wordpress.org/support/topic-tag/sidebar/)
 * [single](https://wordpress.org/support/topic-tag/single/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [haochi](https://wordpress.org/support/users/haochi/)
 * Last activity: [18 years ago](https://wordpress.org/support/topic/adding-adsense-to-sidebar-loop/#post-764361)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
