• 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

Two loops on homepage

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 › Two loops on homepage

This topic is: not resolved

Tagged: grid loop, loop

  • This topic has 1 reply, 2 voices, and was last updated 11 years, 5 months ago by Susan.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • November 13, 2013 at 3:59 pm #72780
    tanzen
    Member

    So I wanted to create two loops on my homepage. One that would display the page's own content, and then a grid loop straight beneath it for fetching the two latest posts from the 'news' category. I couldn't really find a way to do it so I hacked around until I got it working, but I'm not sure this is the right way to be doing things, can anyone tell me what improvements I can/should make to this code?

    Here's a screenshot of what I have:
    http://s18.postimg.org/knrq6sert/2013_11_13_22_55_58.png

    Theme: Metro
    Template: page-home.php

    <?php
     
    //* Add support for Genesis Grid Loop
    //remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'child_grid_loop_helper' );
    
    function child_grid_loop_helper() {
      if ( function_exists( 'genesis_grid_loop' ) ) {
        
        	global $post;
     
    	// arguments, adjust as needed
    	$args = array(
    		'post_type'      => 'post',
    		'posts_per_page' => 2,
    		'post_status'    => 'publish',
    		'paged'          => get_query_var( 'paged' )
    	);
     
    	/* 
    	Overwrite $wp_query with our new query.
    	The only reason we're doing this is so the pagination functions work,
    	since they use $wp_query. If pagination wasn't an issue, 
    	use: https://gist.github.com/3218106
    	*/
    	global $wp_query;
    	$wp_query = new WP_Query( $args );
    		genesis_grid_loop( array(
    			'features' => 0,
    			'feature_image_size' => 0,
    			'feature_image_class' => 'alignleft post-image',
    			'feature_content_limit' => 0,
    			'grid_image_size' => 0,
    			'grid_image_class' => 'alignleft post-image',
    			'grid_content_limit' => 100,
    			'more' => __( '[Continue reading...]', 'genesis' ),
    		) );
    	}
    }
    
    //* Remove the post meta function for front page only
    remove_action( 'genesis_after_post_content', 'genesis_post_meta' );
    
    genesis();

    Two things I have not figured out yet.

    1. How to change the headings of the grid loop from <h2> to <h3>. I had to style the <h2> on that screenshot so that they would be 1.5 rem rather than the default 3 rem. But ideally they would be <h3>.

    2. How to remove the post author from those two posts in the grid loop.

    Any help appreciated.

    February 14, 2014 at 8:12 pm #90403
    Susan
    Moderator

    As it has been a while since you posted your question, I hope you were able to get your issue resolved.

    If not, report back here, and I will escalate for you. Thanks!

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 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

© 2025 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