Injecting Multiple adsense Ads into a WordPress Loop

The versatile code injects for instance adsense ad codes several times into the posts of an index or archive page, starting with a pre-set post, and then repeated in regular intervals (up to a set limit of ads per page).

For example, in a child theme of Twenty Fourteen, this code would be added into content.php at a suitable location:

<?php 
//set the variables//
$nth = 3; //1,2,3,,4...; repeated every n-th post
$snr = 1; //1,2,3...; pre-set start with post nr
$limit = 3; //adsene TOS limit of ads per web page

$lsnr = $snr - 1; // correct for loop counter start at zero

if( $wp_query->current_post >= $lsnr && ( $wp_query->current_post - $lsnr )%$nth == 0 && (int)(( $wp_query->current_post - $lsnr ) / $nth ) < $limit ) { ?>
ADSENSE CODE
<?php } ?>

The example values would start the add in the first post, and repeated every three posts for a maximum of 3 ads.

Gorgeous Miniature Sofa wt Golden Silk Cover

From my workshop:

A miniature 1/3 scale sofa upholstered with golden Dupioni silk. Soft silk covered armrests give this settee a luxurious gorgeous contemporary design look. Comes with two matching silk covered cushions, filled with natural feathers. Fits 18 inch dolls like the American Girl ® Doll, or for your favourite teddy bear.

soft silk upholstered miniature doll settee or sofa with golden dupioni silk cushiions
A gorgeous silk covered miniature settee. Soft upholstered arm rests make this contemporary sofa the favourite seat for your beloved doll or teddy baer.

Overall measurements approximately 35 * 21 * 26 cm (13 1/2 * 8 1/4 * 10 1/2 inch). Seat height about 13cm (5 inch).

Find this and similar items in the ‘silkandart’ etsy shop.