This can be done with a small piece of code, without using any kind of Plugins. So, In order to integrate ads efficiently into your WordPress theme. Open up your index.php file and look for the loop. The loop begins like this..
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
and this loop should end as
<?php endwhile; else: ?>
<p>Sorry, nothing matches that criteria.</p>
<?php endif; ?>
Your Google Adsense code should be placed between the start and the end of this loop. So, just pick a position (after the title or at the end of the content,where ever you want) and place the following code..
<?php if ($wp_query->current_post < 3) { ?>
<!– Google Adsense Code goes here –>
<?php } ?>
Now you have to replace the commented line ( ) with your adsense code, save this file and update your theme. Now your theme should display three units of adsense code in your first 3 posts just like you always wanted.
Nessun commento:
Posta un commento