How to insert Adsense or ads between WordPress posts ?


It is sometimes helpful to place advertisements (or anything else) between the items in the wordpress homepage. It’s also fairly quiet. I do not know if there are plugins offering this service and I confess never to have sought for … Anyway, I will explain here a little trick to place ads between the posts page.

[singlepic id=54 w=320 h=240 mode=web20 float=center]

The solution is simple, you need to increment a php variable on the page. To do this find the following line in your index.php of your template wordpress:

 <?php if (have_posts()) : ?>

Place them just above the following code:

<?php $counter = 0; ?>

It is a simple count of items. Then find the last row of tags (still in index.php):

<?php endif; ?> </div>

This is the last “endif” and the last “div” wich ends the article itself. You only have to put conditions in the counter:

<?php if(1 == $counter) : ?> Votre annonce : html, javascript, ... <?php endif; ?>

To put an ads after the 2nd item :

<?php if(2 == $counter) : ?> Votre annonce : html, javascript, ... <?php endif; ?>

And so on icon wink How to insert Adsense or ads between Wordpress posts ?


Sharing

       


Related Posts



Comments (1)

Trackback URL | Fil RSS des commentaires

  1. tetepsype says:

    i honestly enjoy your writing type, very helpful.
    don’t quit as well as keep posting for the simple reason that it simply just very well worth to look through it,
    impatient to look over much more of your content articles, have a great day :)

Just Comment !





Real Time Web Analytics