Support › Forums › Flex Theme › Ads appear after certain number of posts in blog layout › Reply To: Ads appear after certain number of posts in blog layout
July 16, 2016 at 11:45 am
#1111
Moderator
Try this
add_action( 'genesis_after_entry', 'flex_add_adsense' );
function flex_add_adsense() {
global $wp_query;
//* Adding the ads after 3rd post. You can change the value as per your requirement.
if( $wp_query->current_post == 2 ) {
?>
<!-- PUT YOUR ADSENSE HTML SCRIPT HERE.-->
<?php
}
//* Adding the ads after 6th post.
if( $wp_query->current_post == 5 ) {
?>
<!-- PUT YOUR ADSENSE HTML SCRIPT HERE.-->
<?php
}
}