Two loops on homepage

Community Forums Forums General Discussion Two loops on homepage

This topic is: not resolved

Tagged: ,

This topic contains 1 reply, has 2 voices, and was last updated by  Susan 1 year, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #72780


    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:

    Theme: Metro
    Template: page-home.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, 
    	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' );

    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.



    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!

    Susan @ One Happy Studio I offer theme customizations I tweet!
    I’ve taken up the challenge! – help me answer some of the unanswered posts

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.