0

我如何在创世纪的循环中进行设置。我正在使用 Eleven40 pro,这是 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();
           }

}

//* 运行创世循环 genesis();

我只是想抵消前三个职位。我不想显示最新的 3 个帖子。请帮助向我展示如何做到这一点。我在 lib/structure/loop.php 中还发现了一个代号 loop.php

4

1 回答 1

-1

我最近遇到了一个类似的问题,并写了一篇关于如何在 Genesis Framework 中抵消您的帖子并保持分页的教程。看看 - http://www.steckinsights.com/offset-posts-genesis-framework-without-losing-pagination/

根据教程,它将详细解释这一点,以便您可以根据您的特定情况自定义解决方案,这是我建议放置在 home.php 文件中的代码(可以放在原始问题中共享的代码之后):

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;
}
于 2014-11-01T06:01:20.423 回答