Let’s say that you are ready to place commercial ads on your WordPress blog. If you have signed up for Google’s AdSense, you may have an ad code like the following.
Let’s take a little closer look at the code. The width and height are 728 and 90 pixels, respectively. This ad size is known as Leaderboard. Before placing an ad code, you need to make sure at what size your ad will appear. More importantly, you need to decide where to display an online ad. Possible options you have are below header, sidebar and footer.
Placing Ad Code
Let’s see how to place an online ad right below the header. You have to locate your theme folder at first. Go to wp-content > themes . Then open the folder of the theme you are going to work on. Next, open your header.php with a text editor. Let’s say you have the default WordPress theme. Scroll down all the way to the bottom. And you should find backslash div and hr backslash. That’s where you want to place your code. So give some space between those two lines. You may want to ad br before and after the ad code. And make sure that you enclose your ad code with div such that the ad will align to the center.
The WordPress sidebar is a little more complicated in adding an ad code. Let’s take a look at the default WordPress sidebar. Open sidebar.php. Basically, all you need to do is to see the pattern of li and backslash li. And there are some commands between these tags. Another pattern is a question mark no space php followed by a semi-colon and space with a question mark at the end. So decide where at the sidebar you want to place an ad and look for backslash li or the end of the other pattern. For example, if I want to display an ad below Categories, I should scroll down a little bit and give some space below “wp_list_categories.”
You can also place an ad code at the bottom of the WordPress blog. Depending on the theme you have and how its style sheet is written, you can place an online ad before or after the footer. If you want to place an ad before the footer, you may have to revise your style sheet a little bit so that the whole WordPress blog looks properly.
Anyway, if you have the default theme, just open footer.php. You should find ‘wp_footer’ at the bottom. And just create some space below this line.
In order to place online ads from Google or an ad exchange program, you may have to have some basic knowledge about CSS. Anyhow, you need to decide where to place an ad in the first place. And make sure that you have sufficient space at header, sidebar or footer for the ad you are going to display.