Add adsesnse between grid style posts
-
Hello guys,
I am using a child theme with genesis, and i created a category.php to display post in grid layout.
So now, my post are beeing displayed on 2 columns.
Now i want to add a adsense ad after the first 6 posts.
So it needs to be 6 posts, and after those 6 posts, a area as width as the 2 column post, containing the AD.
Here is the file for category, in pastebin
Clcik here to see the file
I think it needs some tweeks on line 13 , but i do not know how to do it.
Can someone help me with it?
I saw a example from someone, but i think it is not for grid style.Here it is:Ah! Now I understand. Try replacing:
<?php
if (have_posts()) : while (have_posts()) : the_post();
get_template_part(‘post’, ‘homepage’);
endwhile;
with:<?php
if (have_posts()) : $c = 0; while (have_posts()) : the_post();
$c ++;
get_template_part(‘post’, ‘homepage’);
if ($c > 2 ) {
$c = 0;?>
[ insert ad code here ]
<?php
}
endwhile;Here you can see how the end result should look like.
End Result
Thank you !
- The topic ‘Add adsesnse between grid style posts’ is closed to new replies.