• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2784

Original Genesis Tutorials & 6000+ Guaranteed Code

Snippets

  • Consultation
  • Full Access
  • Log in

Add Content After Any Number of Post Excerpts In Any Type Of Archive

In this tutorial, i’ll provide the working code which displays a new widget after any post in any type of archive.

Here’s the screenshot from my local installation of WordPress.

content after excerpt

You can easily change the number from 1 for the first post excerpt to any number.

And you can also easily change the conditional tag to suit your own requirements.

The code uses genesis hooks however you can easily change it to something like woo_after or thesis_after. Please check your themes hook reference first.

Widget After First Excerpt On Front Page Archive

Register for full access

Related Tutorials

  • Add Widget After First Post In Archive Loop
  • Add Different Content Between Excerpts On Any Archive Page
  • Display Ads After Specific Paragraph on Single Posts
  • Add Unique Widgets After Archive Excerpts in Genesis

Reader Interactions

Comments

  1. amit says

    December 1, 2014 at 12:35 pm

    Hi Brad

    Thanks for the code.
    I have used it successfully for few months.
    But now its giving problem in chrome browser. the ad is overlapping with the excepts. this problem is not happening in mozilla or internet explorer.
    2ndly, your site is not visible in india. it shows error “under maintainence”. so i am checking it via proxy.

    Thanks for your valuable tutorials and codes.

    Regards
    Amit

    Log in to Reply
    • Brad Dalton says

      December 1, 2014 at 12:43 pm

      Hi Amit

      Support information. http://wpsites.net/registration/

      Log in to Reply
  2. John Huotari says

    October 14, 2014 at 4:07 pm

    Brad,

    I used a slightly modified version of this code to successfully add a widget after the first post excerpt on category pages.

    However, I’ve been unable to replicate it to properly create new unique widgets after the second and third excerpts. I was able to create new Widgets #2 and #3, but they all show up right under Widget #1 (i.e., after post excerpt #1 and not after post excerpt #2 and post excerpt #3).

    Ideally, I’d like to be able to replicate your code, or use a modified version of it, to create up to about 10 widget sections in the main content area on category pages. Is that possible?

    Here’s the code I used. The first widget works properly, but the second and third don’t.

    Any help you can provide will be greatly appreciated.

    John Huotari
    OakRidgeToday.com

    //* Hook after post excerpt category ad No. 1 on Sept. 19, 2014 */
    
    add_action( 'genesis_after_entry', 'news_after_post_excerpt_category_ad_1' );
    
    function news_after_post_excerpt_category_ad_1() {
    	global $post_count;
    
    	++$post_count;
    
    	if ( ( is_category() ) && 1 == $post_count ) {
    	
    		if ( is_active_sidebar( 'after-post-excerpt-category-ad-1' ) )
    		
    	    	genesis_widget_area( 'after-post-excerpt-category-ad-1', array(
                	'before' => '',
                	'after'	 => '',
    		) ); 
    
      	}
    
    }
    
    
    //* Hook after post excerpt category ad No. 2 on Oct. 13, 2014 */
    add_action( 'genesis_after_entry', 'news_after_post_excerpt_category_ad_2' );
    
    function news_after_post_excerpt_category_ad_2() {
    	global $post_count;
    
    	++$post_count;
    
    	if ( ( is_category() ) && 2 == $post_count ) {
    	
    		if ( is_active_sidebar( 'after-post-excerpt-category-ad-2' ) )
    	
    		    genesis_widget_area( 'after-post-excerpt-category-ad-2', array(
            	    'before' => '',
                	'after'	 => '',
    		) ); 
    
      	}
    
    }
    
    
    //* Hook after post excerpt category ad No. 3 on Oct. 13, 2014 */
    add_action( 'genesis_after_entry', 'news_after_post_excerpt_category_ad_3' );
    
    function news_after_post_excerpt_category_ad_3() {
    	global $post_count;
    
    	++$post_count;
    
    	if ( ( is_category() ) && 3 == $post_count ) {
    	
    		if ( is_active_sidebar( 'after-post-excerpt-category-ad-3-left' ) || is_active_sidebar( 'after-post-excerpt-category-ad-3-right' ) ) {
    		
    			echo '';
    			
    		   	genesis_widget_area( 'after-post-excerpt-category-ad-3-left', array(
                	'before' => '',
                	'after'	 => '',
    			) ); 
    			
    			genesis_widget_area( 'after-post-excerpt-category-ad-3-right', array(
                	'before' => '',
                	'after'	 => '',
    			) ); 
    			
    			echo '';
    		
    		}
    
      }
    
    }
    
    
    /** Register after post excerpt ad widget #1 on category pages on Sept. 19, 2014 */
    genesis_register_sidebar( array(
    	'id'          => 'after-post-excerpt-category-ad-1',
    	'name'        => __( 'After Post Excerpt Category Ad One', 'news' ),
    	'description' => __( 'This is the after post excerpt category ad No. 1.', 'news' ),
    ) );
    /** Register after post excerpt ad widget #2 on category pages on Oct. 13, 2014 */
    genesis_register_sidebar( array(
    	'id'          => 'after-post-excerpt-category-ad-2',
    	'name'        => __( 'After Post Excerpt Category Ad Two', 'news' ),
    	'description' => __( 'This is the after post excerpt category ad No. 2.', 'news' ),
    ) );
    /** Register after post excerpt ad widget #3 left on category pages on Oct. 13, 2014 */
    genesis_register_sidebar( array(
    	'id'          => 'after-post-excerpt-category-ad-3-left',
    	'name'        => __( 'After Post Excerpt Category Ad Three Left', 'news' ),
    	'description' => __( 'This is the after post excerpt category ad No. 3 left.', 'news' ),
    ) );
    /** Register after post excerpt ad widget #3 right on category pages on Oct. 13, 2014 */
    genesis_register_sidebar( array(
    	'id'          => 'after-post-excerpt-category-ad-3-right',
    	'name'        => __( 'After Post Excerpt Category Ad Three Right', 'news' ),
    	'description' => __( 'This is the after post excerpt category ad No. 3 right.', 'news' ),
    ) );
    Log in to Reply
    • Brad Dalton says

      October 15, 2014 at 2:00 pm

      Hi John

      Try this http://wpsites.net/web-design/add-unique-widgets-after-archive-excerpts/

      Log in to Reply
      • John Huotari says

        October 15, 2014 at 7:03 pm

        Thank you, Brad. I’ll take a look, and I very much appreciate it.

        John

        Log in to Reply
  3. Eli Overbey says

    February 14, 2014 at 11:12 pm

    Thanks for all the help. Works great.

    Log in to Reply
  4. Michael says

    February 10, 2014 at 12:15 am

    Works well but there is some blank space, how could I get rid of that?

    Log in to Reply
    • Brad Dalton says

      February 10, 2014 at 12:35 pm

      Simply use Firebug to inspect the white space and find the class and change the values for padding and/or margins.

      Log in to Reply
  5. Michael says

    February 10, 2014 at 12:14 am

    Great stuff, thanks for sharing!

    Log in to Reply
  6. Bob Roman says

    September 12, 2013 at 8:34 pm

    It’s the first time I see this tutorial regarding the Genesis framework…quite good. I remember I asked somebody how do they show content between archive posts and I’ve been told “it’s something custom made”. Glad I found out how to do it.

    Log in to Reply
    • Brad Dalton says

      September 13, 2013 at 6:07 am

      Hi Bob

      You can also use that code on any theme simply by changing the hook from genesis_after_entry to a WordPress hook or a theme specific hook.

      Thanks for the comment.

      Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags
 

Loading Comments...
 

You must be logged in to post a comment.