创世纪主题带有分页的其他自定义偏移循环

问题描述

我正在为Genesis框架创建自定义主题,我需要在首页添加分页(最好添加到其他页面以供将来使用),但是需要偏移量,按 1个或更多数字。这种工作,但没有。如果删除偏移量,则可以看到下一组帖子,如果启用它,它将仅重复第一页。此外,分页不显示“较旧”发布按钮。

这是我的functions.PHP文件中的函数

function offset_post() {
global $post;
$paged = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1;
$args = array(
    'posts_per_page' => get_option('posts_per_page'),'paged' => $paged,'offset'  => '1'
);
$custom_query = new WP_Query( $args );
$temp_query = $wp_query;
$wp_query = null;
$wp_query = $custom_query;
if ( $custom_query->have_posts() ):
    while( $custom_query->have_posts() ):
         $custom_query->the_post(); ?>
         <div class="offset-one">
         <div class="offset-one__post-thumb">
             <?PHP
             if ( has_post_thumbnail() ) {
                 the_post_thumbnail();
             }
             ?>
         </div>
         <div class="offset-one__post-text">
             <div class="offset-one__post"> <?PHP
                 the_title( '<h1 class="offset-one__post-title"><a href="' . esc_url( get_permalink() ) . '" rel=bookmark">','</a></h1>' );
             ?>
             <div class="offset-one__excerpt"><?PHP the_excerpt(); ?></div>
         </div>
     </div>
 </div><?PHP
    endwhile;
endif;
wp_reset_postdata();
prevIoUs_posts_link( 'Older Posts' );
next_posts_link( 'Newer Posts',$custom_query->max_num_pages );  
$wp_query = NULL;
$wp_query = $temp_query;

}

这是front-page.PHP文件中的调用(使用Genesis“ add_action”):

function content_inside_content() {
  echo offset_post();
}

几天以来,我已经尝试过该站点和其他站点的各种解决方案。这是我最近来的。任何帮助将不胜感激

还使用Genesis挂钩会影响博客页面,并希望在可能的情况下使其与主题的挂钩无关。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)