Insert Ads between WordPress Header, Posts & Sidebar

Mrinmay Bhattacharjee | August 13, 2009 More


If you are blogging over Self Hosted WordPress Blog, than this post will tell you How you can insert AD (Advertisement) Code between your WordPress Blog Header & Posts?

wordpress advertisement

It’s recommended that you insert only 728 x 90 Leaderboard (Horizontal) code between your WordPress Blog Header and Posts, as otherwise you whole blog theme interface will not look good!

Login to your WordPress Dashboard and Go to Appearance>> Editor (Theme Editor), now here you have to edit Index.php, Single.php and Page.php. Now look for following Lines:

<?php get_header(); ?>

<div id=”main”>

<div id=”content”>

Now in between <?php get_header(); ?> & <div id=”main”> insert your desired Advertisement (Javascript or HTML) Code along with <div> tag as shown below:

<?php get_header(); ?>

<div id=”ads”>

Insert Advertisement (like Google AdSense) Code Here

</div>

<div id=”main”>

<div id=”content”>

It’s better that you use Center Tags here. The Code with Center Tags will look as follows:

<?php get_header(); ?>

<div id=”ads”>

<center>

Insert Advertisement (like Google AdSense) Code Here

</center>

</div>

<div id=”main”>

<div id=”content”>

It’s all done. Now you will get the Advertisement between your WordPress Blog Header, Posts and Sidebar! If you have any doubt with respect to this, feel free to Ask in Comments Section Below.

Note: If you only want the Advertisement to appear on Homepage, just edit Index.php. Edit accordingly for Page.php (WordPress Pages) and Single.php (WordPress Single Post Pages).

Related: Integrate Google AdSense for Search in WordPress after removing the Sidebar and How to Insert AdSense Between First Post & Second Post in WordPress?

Category: How To, Tips & Tricks, Tutorial, Web, Wordpress

Comments (7)

  1. Saqib says:

    Good post. Will try it definitely. BTW, easy adsense plugin for WordPress is also good.

  2. Matt says:

    I inserted the code but when I added before and after, it centered the ad plus a bunch of other things on the page. What can you insert so it centers the ad only?

    Also any simple code to add in a bit of space between header and the ad, then between the ad the post/sidebar?

    Thanks.

  3. Matt says:

    its was meant to say “when I added ‘center’ tags before….”

  4. mrintech says:

    Hello Friend,

    First of all Let me see your WordPress Blog, give me your Blog Address :) Also if possible E-mail me your index.php and single.php files using the Contact Page

    Thanks :)

  5. Thanks a lot you solve my Problems

  6. Matt says:

    I got it working all ok, I put a Div Style command in to centre the ad.

    Thanks for this article, its great.

  7. mrintech says:

    Glad to know that it worked :)