WordPress.org

Forums

adding adsense to sidebar loop..? (3 posts)

  1. ivyology
    Member
    Posted 7 years ago #

    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]

  2. ivyology
    Member
    Posted 7 years ago #

    I got a new theme so problem solved (kinda)

  3. haochi
    Member
    Posted 7 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic