- This topic has 5 replies, 3 voices, and was last updated 5 years, 11 months ago by .
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
- You must be logged in to reply to this topic.
Support › Forums › Flex Theme › Ads appear after certain number of posts in blog layout
Hi support,
Would it be possible to setup Ads appear after certain number of posts in blog layout? Here is the screenshot: http://prntscr.com/bsspud
Regards,
Joseph, try code shared here – http://www.basicwp.com/add-new-widget-between-posts-genesis/
2nd option:
You will add this kind of code in your front-page.php (if you want for home page only) or functions.php file.
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
}
}
Note: I did not test it. Before editing the file you will keep a backup of your child theme.
Hi Chinmoy,
I tested your code, and it is working great. I would like to add another code after the 6th post. Could you help me how can I add?
Hi Davinder,
Would you please include this feature into “Flex – Featured Posts” widget? As I am using “Flex – Featured Posts” and the method is doesn’t work with it.
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
}
}