ThemeLab's Blog

Stay up to date with our newest WordPress themes, WordPress plugins, WordPress tutorials, and other announcements.

Displaying Adsense and other ads with WordPress

Last Updated on by

I’m sure while browsing for WordPress themes, you’ve come across some that are advertised as being Adsense ready. What does this mean exactly? Basically this means the WordPress theme has been designed to have space for Adsense ads in the available dimensions. In reality, nearly every WordPress theme is potentially “Adsense ready” as any theme can have ads placed, wherever you want. In this tutorial, we’ll go over several ways on how to insert ads into your WordPress themes. You can do this through:

  • A variety of WordPress plugins
  • Inserting raw ad code directly into the post
  • Inserting ad code directly into your template files

If you want valuable tips in inserting ads into your WordPress themes, read on.

There are many popular ad sizes on the internet today. Some from Adsense include:

  • Leaderboard (728×90)
  • Banner (468×60)
  • Skyscraper (120×600)
  • Square (250×250)
  • Medium Rectangle (300×250)
  • Large rectangle (336×280)
  • Wide Skyscraper (160×600)

Some are tall, some are wide, some are square. Depending on the structure of your theme, you’ll likely have many ideal areas for different sized ads.

Using WordPress Plugins

Probably the easiest way to start serving up ads on all of your posts and pages automatically is using a WordPress plugin. I’ve found a few good ones worth checking out.

  • Adsense Manager – This is definitely one of the most popular plugins out there for managing advertisements with over 50,000 downloads. Despite the name, not only does it support Adsense, but a number of other ad publishing services as well. Among these include Adbrite, AdGridWork, AdOpinion, AdRoll, Commission Junction, CrispAds, ShoppingAds, YPN, and WidgetBucks.
  • All in One Adsense and YPN – This plugin is very easy to use. All you need to do is insert your Adsense or YPN publisher ID, and it will automatically insert your ads in all of your posts, on the fly. It allows you to choose the size and colors as well.

Those two plugins should be more than enough for now, however there are many other Adsense plugins available here.

Inserting Code Manually

Another way to insert ads into posts or pages is to simply paste the code into your post editor. Make sure you choose the Code editor, as pasting in the Visual editor will simply format the code into text, like this:

Adsense code WordPress

In the code editor, your Adsense (or any other ad) will be displayed properly on your page. While inserting your code into a post or page, it should look something like this:

Adsense Code Editor WordPress

The live blog post will look like this after successfully inserting a 468×60 Google ad.

Adsense WordPress Saved

I honestly wouldn’t recommend this method just because there are more efficient methods availalble. Even if you want to selectively insert ads in specific posts, the plugins above could do that as well by providing a simple tag to insert in your posts instead.

Inserting code directly in your template

If you’re comfortable editing template files, this will probably be the best way to effectively insert sitewide advertisements on your WordPress blog. Most WordPress themes are broken up into several parts:

  • Header – The top of the theme.
  • Sidebar – Take a wild guess.
  • Main Index – The homepage listing of posts. Could apply to pages and single posts if not defined in other files.
  • Single Post – Individual blog posts.
  • Page Template – Static pages

For now I’m not going to get into conditional tags for even greater control, and will save that for a future tutorial. For our example, we’re going to insert a 468×60 ad directly below the content on the static pages. This will affect all static pages on the site, such as About. Simply insert your Adsense code like so:

Adsense WordPress Page Template

Your static pages will all have Adsense ads displayed like this:

Congratulations!  You can now use ads with WordPress

That’s all. If you liked the tutorial feel free to comment, share, subscribe to the feed. Enjoy!

  • http://www.lifeofjustin.com Justin

    Great article about Adsense. Now if Only I could attract more clicks :(

  • http://i-martian.quotaless.com/ I-martian

    really good , i still didn’t put any ads code in any of my sites , but it’s really to know where my sponsors will be putting their ads :)

    @justin ,, clicks . isn’t that big problem ;)

  • http://www.websitestocomputers.com Curt

    You can also just add the code into a text widget and put it into the sidebar.

    I had problems with the two plugins you mentioned. But then, it could have just been me.

  • Leland

    @Curt: That’s a great idea, I forgot to mention the text widgets. Just wondering, what problems were you having with the two plugins I mentioned?

    Thanks for commenting everyone.

  • John Carnegie

    Thanks for a very informative post. I will send your blog link to my readers!

  • http://www.mad-about-kids.com Michelle

    I am a complete newbie to wordpress–I just started transferring my blogger blog to WP a few days ago. Bought my domain, got my host, all of that. And I’ve been looking for a site like yours where there are things like this spelled out for people who aren’t techies! :) I want a good theme that looks nice…and I want ads, but I didn’t know how to put the two together. Now I do, thanks to you. I definitely plan on checking through the rest of your site! :) (And BTW–if you look at my site at all, please don’t judge…it is not even close to ready for public viewing, LOL!)

  • Leland

    @Michelle: I think you’re off to a good start. Already have a nice looking theme (although it’s not from here :P) rewritten URL’s, etc. I think all you have to do is replace those “dummy” ads in your theme with your own advertisements. I’d imagine you’d have to edit your template file to do this. Keep up the good work!

  • http://www.mad-about-kids.com Michelle

    Oh, that theme isn’t staying–it was the only theme I found that had ad space that wasn’t ugly , LOL! See, now I can look at other themes and find something better now that you clued me in on how to insert ads in any theme. :) :) But thanks for the vote of confidence! :)

  • http://www.fashionzealot.net Bunny

    Thanks for the tip but I want my ads to appear after the post title. Where do I paste the adsense code? Thanks!

  • Leland

    @Bunny: Well I’m not entirely sure how you’re theme is structured. Either on index.php or single.php (depending if you want it on your main index or single post pages) you’d probably insert it directly after the code which looks like this:

    <h2 class="title"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>

    Try that and see if it works…

  • http://problogging.netsons.org domin mercier

    Great advice… thanks!

    Domin (that don’t use adsense, yet)

  • sana

    hi i m facing problem with implementation of code i have used alot of method but i could be successful plz help me

  • Leland

    @sana: What exactly is the problem?

  • http://tellitlikeitiz.wordpress.com Tiiz

    Can you use adsense with the FREE WordPress or do you have to have the premium service?

  • Leland

    @Tiiz: Pretty sure it’s not allowed on WordPress.com without the premium service.

  • http://stuffheaven.com/ BigBoss

    Another awesome tutorial..Gonna try adsence in my blog..

    Thank you !!

  • http://boltayjao.blogspot.com jazzian

    Thanx for a great piece of info, i am gonna make new wordpress blog and this info will help me a lot :-)

  • Rastgoo

    Nice article but as others said, click conversion matter’s.

  • http://www.ranacorp.com Rana

    Thanks for your valuable tips about adsense. It works like a charm.

  • http://www.commeercialtenantsblog.com Lee Sterling

    I’ve created 4 125 X 125 ads for some friends to insert on my blog. I’ve uploaded the ads to the image file. I believe I’m supposed to put some code in the footer.php file, but I’m unsure as to the required code and where I’m supposed to put it. Can you advise? THANKS.

  • Web

    See link to add Adsense to your wordpress blog without using any plugins!!

    http://www.webdigi.co.uk/blog/2009/add-google-adsense-to-wordpress-without-plugins/

  • L Graham

    Is there a way I can use Adsense on my free wordpress.com blogs.

    If u know about a workaround or a trick or a tip on the same..plz do tell me.

    Thanks and regards
    Leo

  • parth

    @Leland

    Hie very nice tutorial u gave. But i have a question. I went through wordpress.org and they clearly stated that u cant have ads on free wordpress blogs.

    if you want to have ads you have to be registered with wordpress.com. And here u gave an beautiful tutorial on how to get ads. so m very much confused.

    Please reply m looking forward to get some helo from i have worked hard on my current blog. and dont want to do all over again .

    Thanks…

    • Leland

      I think you have it mixed up. WordPress.com doesn’t allow ads (unless you’re VIP or enterprise, etc.).

      On self-hosted WordPress sites you can put all the ads up you want.