【发布时间】:2021-03-21 16:17:16
【问题描述】:
我正在使用 WordPress 自定义查询,我想跳过每个页面上的第一篇文章,即第 1、2、3 页... 我有一个问题,但不知道如何只跳过第一个帖子。
Suppose there are 19 posts id 1,2,3 ... 19,
I want 1st post having id 19 should be ignore on every page with posts_per_page => 6
So, on page 1 posts of these id's will be shown : 18,17,16,15,14,13 and
on page 2 posts of these id's will be shown : 12,11,10,9,8,7 and
on page 3 posts of these id's will be shown : 6,5,4,3,2,1
在这里我们可以看到第一个帖子(id => 19)在每个页面上都被跳过,这就是我想要的,我该如何实现?
查询:-
$catID = 13;
$page = $_POST['page'];
$output = '';
$total_pages = 0;
$args = [
'posts_per_page' => 6,
'cat' => $catID,
'order' => 'DESC',
'paged' => $page,
];
$posts = new WP_Query($args);
注意:我使用了 offset => 1 但这不是我想要的。
【问题讨论】: