• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Is it possible to display ADS on first three posts on archive page?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Is it possible to display ADS on first three posts on archive page?

This topic is: not resolved
  • This topic has 2 replies, 2 voices, and was last updated 5 years, 10 months ago by wparrow.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • May 10, 2017 at 2:19 am #206228
    wparrow
    Member

    Hi,
    To increase the click though rate, I want display ADS via archive page at "genesis_before_entry" position but for first three posts only.
    The code should be.

    If is category
    Count the post
    If posts < 4
    Display ADS
    End if
    End if

    I tried to write the code like below, but it does not work. Could you please help me correct it?

    <?php if (is_category()) {
    <?php if (have_posts()) : ?>
    <?php $count = 0; ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php $count++; ?>
      <?php if ($count == 4) : ?>
    <?php echo "This is the ads"; ?>
    <?php endif; ?>
    <?php endwhile; ?>
    <?php endif; ?>
    } ?>

    I placed the code at "genesis_before_entry" in Genesis Simple Hook but it does not work

    Thanks for your help!
    TOM

    May 10, 2017 at 10:16 pm #206274
    James Chai
    Member

    Why not just insert your 'AD' code into 'Archive Intro'?

    That way it will always show first and you can show as many as you like via column classes.


    Marketing, Sales and WordPress Growth Hacking http://www.smbpress.com

    May 10, 2017 at 10:47 pm #206276
    wparrow
    Member

    Thanks jchai for notify me about column class. I will add ADS on archive intro as well.

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble