WordPress.org

Ready to get started?Download WordPress

Forums

Google adsense swap with image (5 posts)

  1. aitchison21
    Member
    Posted 7 years ago #

    Hi

    I would like to ask if it is possible to have an image on the main page of a post and then when that post heading is clicked it swaps the image with an adsense block?

    If not, is there a way to just have the adsense block on the post only (single page) and not the main page.

    I am trying to keep the number of ads down to 3 on the main page.

    Thanks in advance

    http://www.stevenaitchison.co.uk/blog

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    Instead of putting the adsense code in the post itself, put it on your template where you want it to be. If you put the adsense in the single.php file, that's the Single Post template, and so the adsense will only show up on the single post pages.

    A good rule of thumb for writing stuff in your blog: If you're putting anything in the post other than the actual content of the actual post, you're doing something wrong.

  3. aitchison21
    Member
    Posted 7 years ago #

    Hi Otto

    Thanks for the advice.

    Only problem is I have no 'single'. I have page.php but no single. Where would I put it? (sorry if it sounds a silly question)

  4. moshu
    Member
    Posted 7 years ago #

    Where would you put what? The single.php? ALL the template files should be in the theme folder.
    http://codex.wordpress.org/Theme_Development#Theme_Template_Files_List

    EDIT. Save your index.php (from the theme) as single.php and edit in the way you need.

  5. aitchison21
    Member
    Posted 7 years ago #

    Hi Moshu

    thanks for this. I copied the index.php and made a single.php file and put the adsense code in there. works a treat.

    Otto42 - thanks for your help as well

Topic Closed

This topic has been closed to new replies.

About this Topic