在wordpress帖子循环中跳过三篇帖子

在wordpress帖子循环中跳过三篇帖子,wordpress,Wordpress,如何跳过wordpress中的三篇文章?谢谢 while ( $query_custom->have_posts() ) : $query_custom->the_post(); include( locate_template( 'content-' . $style . '.php' ) ); endwhile; 在functions.php中添加此代码 add_action('pre_get_posts', 'skip_posts_wordpress'); func

如何跳过wordpress中的三篇文章?谢谢

while ( $query_custom->have_posts() ) : $query_custom->the_post();
    include( locate_template( 'content-' . $style . '.php' ) );
endwhile; 

在functions.php中添加此代码

add_action('pre_get_posts', 'skip_posts_wordpress');
function skip_posts_wordpress($query){

    if(!is_admin() && $query->is_archive()){
        $query->set('offset', 3);
    }
}
或尝试

$query_custom = new WP_Query( array( 'offset' => 3 ) );
 while ( $query_custom->have_posts() ) : $query_custom->the_post();
      include( locate_template( 'content-' . $style . '.php' ) );
 endwhile; 
您只需添加:

$query_custom = new WP_Query( array( 'offset' => 3 ) );

while ( $query_custom->have_posts() ) : $query_custom->the_post();

你想跳过任何3篇文章,前3篇还是最后一篇?前3篇!谢谢:)尝试回答的解决方案,让我知道它是否有效
pre\u get\u posts
是更好的方法。第二个代码有效!但是我面临一个问题,在帖子上有一个“加载更多”按钮,所以在点击加载更多后,显示的帖子会被复制。我应该在这里发布整个主题文件代码来找出原因吗?谢谢!我仍然面临一个问题,在帖子上有一个“加载更多”按钮,所以点击按钮后,显示的帖子会重复。我应该在这里发布整个主题文件代码以找出原因吗?我刚刚向您发送了一个问题!真高兴你的帮助!谢谢