Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php wordpress排除最后一篇文章_Php_Wordpress_Twitter Bootstrap - Fatal编程技术网

Php wordpress排除最后一篇文章

Php wordpress排除最后一篇文章,php,wordpress,twitter-bootstrap,Php,Wordpress,Twitter Bootstrap,较短的问题 我用这个来获取最近的帖子 $args = array( 'posts_per_page' => 20, 'category' => $category ); $postslist = get_posts( $args ); 但是我怎么排除最后一篇文章呢?因为对于最新的帖子,我想做一些不同的事情,例如包括摘录。 我可以单独称之为 我做了一些搜索,显然有偏移量,但我不确定它是否会干扰分页 更长的解释 (实际上,我可以做一些类似$I=0的事情,并在foreach循环中递增

较短的问题

我用这个来获取最近的帖子

$args = array(  'posts_per_page' => 20,  'category' => $category );
$postslist = get_posts( $args );
但是我怎么排除最后一篇文章呢?因为对于最新的帖子,我想做一些不同的事情,例如包括摘录。 我可以单独称之为

我做了一些搜索,显然有偏移量,但我不确定它是否会干扰分页

更长的解释 (实际上,我可以做一些类似$I=0的事情,并在foreach循环中递增它,如果它是$I==0,我可以显示一个摘录..但是事情变得复杂了,因为我想用引导列来显示它们,所以目前我有一个代码,它将每个帖子放在col-md-3中,但是如果它在当前行中已经有4列,那么do在下一排

    $args = array(  'posts_per_page' => 20,  'category' => $category );
    $postslist = get_posts( $args );

    $i = 0;
    foreach ( $postslist as $post ) :
    $i++;
    setup_postdata( $post ); ?> 


    <?php if($i<4) : ?>

    <div class="col-md-3">  the_title() and other stuff </div>

    <?php else : 
    $i = 0; ?>

    <div class="row">
      <div class="col-md-3> the_title() and other stuff </div>
    </div>
$args=array('posts\u per\u page'=>20,'category'=>$category);
$postslist=get_posts($args);
$i=0;
foreach($postslist as$post):
$i++;
设置_postdata($post);?>
_title()和其他东西
根据,
get_posts
有一个
offset
选项

只需像这样使用:

$args = array('posts_per_page' => 20, 'category' => $category, 'offset' => 1);
$postslist = get_posts($args);

这将返回除最后一篇之外的20篇最新文章。

这也是我的问题,将抵消对分页的干扰?@Marko-这很容易测试。但是,不,我想不会。sql查询不是执行
0,20
20,20
,而是
1,20
21,20