php - How to show other content (such as an ad) after every "X" number of posts -


i have wordpress website , want implement adsense ads it.

i have 30 posts per page want show ads after every 7 posts, how can this? using method 3 ads in 10 posts, , after 10 posts no ads showing:

<center><?php if( $wp_query->current_post == 1 ) : ?>  adsense code here  <?php elseif( $wp_query->current_post == 3 ) : ?>  adsense code here <?php elseif( $wp_query->current_post == 7 ) : ?>  adsense code here <?php endif; ?></center> 

i want show ads after every 7 posts, possible in 1 code line ?

you need put 1 condition here :-

if( ($wp_query->current_post) % 7 == 0 ):   adsense code here  endif; 

by 0 reminder after every post count multiple of 7 7, 14, 21 etc.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -