6

如何跳过 WordPress 中的第一篇文章?

<?php
$recentPosts = new WP_Query();
$recentPosts->query(array('showposts' => 6,'post_type' =>array('stiri')));
?>
<?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
4

2 回答 2

14

使用offset参数:

<?php
$recentPosts = new WP_Query( 'offset=1' ) );
$recentPosts->query(array('showposts' => 6,'post_type' =>array('stiri')));
?>
<?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
于 2012-07-28T01:18:48.303 回答
0

使用偏移量

$recentPosts = new WP_Query (
   array(
     'post_type'      => 'stiri',
     'post_status'    => 'publish',
     'posts_per_page' => 6, // all = -1
     'orderby'        => 'date',
     'order'          => 'DESC',
     'offset'         => 1
   )
);
于 2021-10-21T12:55:15.930 回答