• Home
  • Blog
  • Showcase
  • Setup Docs
    • Sunshine Help
    • Flex Help
  • Support
    • Support Area
    • Contact us
    • Feedback
  • Connect
    • Newsletter
    • Twitter
    • Facebook
  • My Account
  • Flex
  • Sunshine
Support : Simple Pro Themes

Support : Simple Pro Themes

[Resolved] Ads appear after certain number of posts in blog layout

If you have purchased a product, please enter the email address that you used to register at time of purchase.
Log In
Lost Password

Create an Account
  • Your username must be unique, and cannot be changed later.
  • We use your email address to email you a secure password and verify your account.

Support › Forums › Flex Theme › Ads appear after certain number of posts in blog layout

  • This topic has 5 replies, 3 voices, and was last updated 5 years, 11 months ago by Chinmoy Paul.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • July 14, 2016 at 12:12 pm #1093
    Joseph
    Participant

    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,

    July 14, 2016 at 1:32 pm #1096
    Davinder Singh Kanith
    Moderator

    Joseph, try code shared here – http://www.basicwp.com/add-new-widget-between-posts-genesis/

    July 14, 2016 at 2:02 pm #1104
    Chinmoy Paul
    Moderator

    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.

    July 16, 2016 at 8:53 am #1107
    Joseph
    Participant

    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?

    July 16, 2016 at 10:41 am #1109
    Joseph
    Participant

    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.

    July 16, 2016 at 11:45 am #1111
    Chinmoy Paul
    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
      }
    
    }
  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Log In

Copyright © 2022 · Simple PRO Themes for Genesis Framework · About · FAQs · Contact · Affiliates