0

How do I off set in the loop in genesis. I am using Eleven40 pro and this is the home.php

//* Add Genesis grid loop
    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'eleven40_grid_loop_helper' );
    function eleven40_grid_loop_helper() {

    if ( function_exists( 'genesis_grid_loop' ) ) {
    genesis_grid_loop( array(
          'features' => 1,
          'feature_image_size' => 0,
          'feature_image_class' => 'alignleft post-image',
          'feature_content_limit' => 0,
          'grid_image_size' => 'grid-featured',
          'grid_image_class' => 'grid-featured',
          'grid_content_limit' => 250,
          'more' => __( '[Continue reading]', 'eleven40' ),
           ) );
           } else {
           genesis_standard_loop();
           }

}

//* Run the Genesis loop genesis();

I just want to offset the first three posts. I don't want to show the latest 3 posts . Please help in showing me how to do this. There is also a code name loop.php that I found in lib/structure/loop.php

Youssif Saeed
  • 11,789
  • 4
  • 44
  • 72
Anas Khan
  • 19
  • 10

1 Answers1

-1

I recently ran across a similar problem and wrote a tutorial on how to offset your posts and maintain pagination in the Genesis Framework. Take a look - http://www.steckinsights.com/offset-posts-genesis-framework-without-losing-pagination/

Based on the tutorial, which will explain this in detail so you can customize the solution to your particular situation, here is the code I would suggest placing in your home.php file (can be placed after the code shared in the original question):

function myprefix_query_offset(&$query) {

if ( ! $query->is_main_query() ) {
    return;
}

$offset = 1 ;

$ppp = get_option('posts_per_page');

if ( $query->is_paged ) {

    $page_offset = $offset + ( ($query->query_vars['paged']-1) * $ppp );

    $query->set('offset', $page_offset );

}
else {

    $query->set('offset',$offset);

}
}
add_action('pre_get_posts', 'myprefix_query_offset', 1 );

add_filter('found_posts', 'myprefix_adjust_offset_pagination', 1, 2 );
function myprefix_adjust_offset_pagination($found_posts, $query) {

    $offset = 1;

    if ( $query->is_posts_page ) {
        return $found_posts - $offset;
    }
    return $found_posts;
}