For the ad to only appear under the first post and nowhere else,
The Quick Way
Edit index.php and place the following code wherever you want the ad to appear:
- if ($wp_query->current_post <>
- adsense_deluxe_ads('above_posts');
- } ?>
Replace adsense_deluxe_ads(’above_posts’); with your adsense code. If you want the ad to appear below the post, you would paste the above before
We’ve similarly placed 3 link units at the top of first three posts on our home page using this code:
- f ($wp_query->current_post <>
- {
- include('adsense_indexpage_firstthreeposts_linkunit.php');
- }
- gt;
The Long Way (We are no longer using this method, now that we’ve discovered the quick way)
- Open your theme’s index.php, and find this line:
- if (have_posts()) : while (have_posts()) : the_post(); ?>
- Immediately above that, paste this:
- $postnum = 1;
- $showadsense1 = 1;
- ?>
- Staying in index.php, scroll down to this part:
class="postmetadata">Posted in ', ') ?> | 'Edit', '', ' | '); ?> 'No Comments »', '1 Comment »', '% Comments »'); ?>
- endwhile; ?>
- if ($postnum == $showadsense1) {
- echo '
- Your adsense code goes here
- ';
- } ?>
-
- $postnum++; ?>
Paste the adsense code where it says Your adsense code goes here.
If you are using Adsense-Deluxe plugin, you can replace
- echo '
- Your adsense code goes here
- '
with the plugin provided code like
- 'adsense_below_first_post'); ?>
This can similarly be extended to archives and search page by editing archive.php and search.php respectively.


No comments:
Post a Comment