I am trying to place Google ads among every 7 posts in the category pages of my homepage and WordPress site.
I found this code on the WordPress forum and tried it myself by putting it, it did not work. I'm not sure how to use this code in my theme. The code I got is this.
if (has_posts ()): $ count = 0; While (is_pause ()): the_post (); // First if (($ count> 1) & amp; amp; ($ count% 5 == 0)) {? & Gt; & Lt; Div & gt; [Adcod] & lt; / Div & gt; By & lt;? } $ Count ++;
My topic is relative code from index.php.
if (has_posts ()): while (has_posts ()): the_post (); ? & Gt; & Lt ;? Php if (floatwal (get_bloginfo) & lt; "3.6") // Original post formats get_template_part ('/ post-templates-pre-3-6 / entry', Get_post_format ()); } Else {// WP 3.6+ post formats get_template_part ('include / post templates / entry', get_post_format ()); }? & Gt; & Lt ;? Php timeline; end if; ? & Gt;
I want to know how do I enter code according to the upper code of index.php? Thanks to
You can create a $ counter on it Based on the ad code, the final code will be for you:
$ counter = 1; If (is_pause ()): while (is_pause ()): the_post (); ? & Gt; & Lt ;? Php if ($ counter% 7 == 0) {? & Gt; [Adcode] & lt ;? Php} if floatwal (get_bloginfo ('version')) in (get_template_part) ('/ include post-template-pre-3) & lt; "3.6") -6 / entry ', get_post_format ()); } Else {// WP 3.6+ post formats get_template_part ('include / post templates / entry', get_post_format ()); }? & Gt; & Lt ;? Php $ counter ++; Endwhile; end if; ? & Gt;
We only raise $ counter, and display [adcode] after every seven posts.
No comments:
Post a Comment