WordPress – display ADS on your sidebar v5

Version: 4.1
Revision: 34 Build 22

WordPress – display ADS on your sidebar v5

ads_exampleIntroduction:
this project was driving me to the wall! I have to re-write my entire “125 pixel ADS” – source code, so that it could find the images from your costume – template – files. Also, this version is not JavaScript, infact, it was written in PHP with CSS script. So, it’s a little harder for me to build. But, don’t panic! I already did a test run.

Anyway, all you need to do is follow the instruction, carefully!

1.] Login to your Cpanel and look for your theme folder.

Directory: /wp-content/themes/* costume – theme – folder/…

2.] Look for your “header.php” file and add this line.

<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/css/blocked_template.css"></script>

Notes: if you saved the file with a different name, you must modify the CSS directory.
If you don’t, your sidebar will go funny…

/* --- Copy these code into your 'blocked_template.css' --- */

#sidebar li li.ad1 {
  float:left;
  margin: 0 5px 5px 0;
  width:125px;
  }
#sidebar li li.ad2 {
  float:left;
  margin: 0 0 5px 0;
  width:125px;
  }
#sidebar li li.ad3 {
  float:left;
  margin: 0 5px 0 0;
  width:125px;
  }
#sidebar li li.ad4 {
  float:left;
  margin: 0 0 0 0;
  width:125px;
  }

/* --- Copy these code into your 'blocked_template.css' --- */

3.] Back into your server, you’ll need to create a new “template.php” file. Just give it a simple name, like: ‘ads125.php’. After that, you’ll need to edit your file and add these code with your prefered ADS.

Notes: you’ll need to create a seperate directory (costume stylesheet directory) for your image-banners. The directory is called: ‘banner_images’.

<ul class="banner125 clearfix">
  <li class="ad1">
    <a href="<?php bloginfo('url'); ?>"><img src="<?php bloginfo('template_directory'); ?>/banner_images/ads125.gif" style="display:block;margin:0;padding:0;" alt="125x125 banner ad" /></a>
  </li>
  <li class="ad2">
    <a href="<?php bloginfo('url'); ?>"><img src="<?php bloginfo('template_directory'); ?>/banner_images/ads125.gif" style="display:block;margin:0;padding:0;" alt="125x125 banner ad" /></a>
  </li>
  <li class="ad3">
    <a href="<?php bloginfo('url'); ?>"><img src="<?php bloginfo('template_directory'); ?>/banner_images/ads125.gif" style="display:block;margin:0;padding:0;" alt="125x125 banner ad" /></a>
  </li>
  <li class="ad4">
    <a href="<?php bloginfo('url'); ?>"><img src="<?php bloginfo('template_directory'); ?>/banner_images/ads125.gif" style="display:block;margin:0;padding:0;" alt="125x125 banner ad" /></a>
  </li>
</ul>

4.] Save your progress and add this line into yout “sidebar.php”. But, you must place this ‘ads125.php’ file in the same directory as your “sidebar.php”.

<li>
  <?php include (TEMPLATEPATH . '/ads125.php'); ?>
</li>

5.] You’re good to go!

Copyrighted By Lair360

Comments are closed.