free hit counters
If you are using Internet Explorer as your browser please be running at least IE 7 or above. This site does not support IE 6 or below. Go here for the latest free version including easy download and installation instructions If you want to make it real easy on yourself, download Firefox , the most popular browser in the world. It's free and simple. You'll be so glad you did.
May
7
2009

Place a row of ads on your page

162

This is cool and simple way of placing as many ads as you want on your site…

First thing is to upload your ads into the custom/images folder on your server

The ads in this example are 125 x 125 which is pretty typical

Next, create a simple function in your custom_functions.php to add the ads, put div tags for the ads, and give it a class name…

function ad(){?>
<div class="ads">
</div>
<?
}

Next, add an unordered list of the ads your going to use between the two div tags and include the path to the image. Your path may be different than the example below…

function ad(){?>
<div class="ads">
<ul >
<li><img src="http://www.mysite.com/wp-content/themes/thesis/custom/images/ad1.png"></li>
<li><img src="http://www.mysite.com/wp-content/themes/thesis/custom/images/ad2.png"></li>
<li><img src="http://www.mysite.com/wp-content/themes/thesis/custom/images/ad3.png"></li>
<li><img src="http://www.mysite.com/wp-content/themes/thesis/custom/images/ad4.png"></li>
</ul>
</div>
<?
}

I decided to put them right under the header so I placed them with the appropriate hook. Here’s how the entire function looks…

function ad(){?>
<div class="ads">
<ul >
<li><img src="http://www.mysite.com/wp-content/themes/thesis/custom/images/ad1.png"></li>
<li><img src="http://www.mysite.com/wp-content/themes/thesis/custom/images/ad2.png"></li>
<li><img src="http://www.mysite.com/wp-content/themes/thesis/custom/images/ad3.png"></li>
<li><img src="http://www.mysite.com/wp-content/themes/thesis/custom/images/ad4.png"></li>
</ul>
</div>
<?
}
add_action(’thesis_hook_after_header’,'ads’);

Next, add the class to your custom.css and include one for the unordered list of images…

.custom .ads{}
.custom .ads ul li{}

These are the properties and values I used, yours may be different…

.custom .ads{padding: 1em; width: 94em; height: 10em;}
.custom .ads ul li{display: inline; margin-right: 1em;}

This is a really simple, fast, and effective way of placing ads on your site. Remember you can add as many ads as you want. you can also place them vertically, or in the sidebar, in the footer, in the header, etc. The possibilities are endless.

Leaving a comment with code in it...

If you would like to leave a comment and you have examples of code you want to show, you must "escape the code". This allows the entire code to show correctly by inserting certain variable around certain tags to make them show. If you don't "escape the code" your code will show up broken, mangled, and it won't be able to be seen correctly. "Escaping the code" is very simple...

  1. Copy your code you want to show
  2. Click here to go to the site to escape the code
  3. Follow the directions, it's so easy
  4. Once you have the escaped code copied, paste it in the comments area where you want
  5. Now you can enjoy life


Go ahead, leave a comment...

{ 2 comments… read them below or add one }

Milad May 14, 2009 at 4:55 pm

How can you put the ads on the side bar going vertical two columns of ads?
Thanks in advance.
Great site by the way

Reply

Nasty May 15, 2009 at 8:53 am

Put the above code that is between the two div tags in a text widget.

Break the lists up into pairs but give them all the same class name

<ul class="ads">
<li><img src="http://www.mysite.com/wp-content/themes/thesis/custom/images/ad1.png"></li>
<li><img src="http://www.mysite.com/wp-content/themes/thesis/custom/images/ad2.png"></li>
</ul>
<ul class="ads">
<li><img src="http://www.mysite.com/wp-content/themes/thesis/custom/images/ad3.png"></li>
<li><img src="http://www.mysite.com/wp-content/themes/thesis/custom/images/ad4.png"></li>
</ul>
</div>

Reply

Leave a Comment

Previous post: Style any post differently than the rest with the css class box

Next post: Highlight any part of your post or page