Skip to main content
Escaped inline markup. Reindented code.
Source Link
Charles Clarkson
  • 3.7k
  • 1
  • 18
  • 19
//* 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();`
  1. How to change the headings of the grid loop from to <h2> to <h3>. I had to style the on<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.

//* 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();`
  1. How to change the headings of the grid loop from to . I had to style the on that screenshot so that they would be 1.5 rem rather than the default 3 rem. But ideally they would be .

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

//* 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();`
  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.

Source Link
urok93
  • 4k
  • 12
  • 65
  • 104

Multiple loops in Genesis

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

//* 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 to . I had to style the on that screenshot so that they would be 1.5 rem rather than the default 3 rem. But ideally they would be .

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

Any help appreciated.