Displaying Adsense and other ads with WordPress

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!

Comments  Leave a Reply

  1. @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 .


    1. 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.

  2. 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

    1. You can either pay for WordPress.com VIP, or get a self-hosted WordPress blog (tutorial here), or use Blogger.

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


  4. 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.

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

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

  7. Thanx for a great piece of info, i am gonna make new wordpress blog and this info will help me a lot πŸ™‚

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

    Thank you !!

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

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

  11. @sana: What exactly is the problem?

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

  13. Great advice… thanks!

    Domin (that don’t use adsense, yet)

  14. @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…

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

  16. 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! πŸ™‚

  17. @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!

  18. 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!)

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

  20. @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.

  21. 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.

  22. 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 πŸ˜‰

  23. Great article about Adsense. Now if Only I could attract more clicks πŸ™

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!