如何使用wordpress跳过我的第一篇文章?

时间:2016-12-05 05:23:04

标签: php wordpress

<?php
$pages = get_posts( array(
    'post_type' => 'post',
    'post_status' => 'publish',
    'orderby' => 'post_date',
    'orderby' => 'meta_value_num',
    'posts_per_page' => 4

) );

echo $post_id = $pages->ID ;
echo $post_thumbnail_id = get_post_thumbnail_id( $post_id );  

?>

在上面,代码我想跳过我的第一篇文章并显示其余部分。

1 个答案:

答案 0 :(得分:1)

试试这个:

使用get_posts()参数的offset参数。

$pages = get_posts( array(
    'post_type' => 'post',
    'post_status' => 'publish',
    'orderby' => 'post_date',
    'orderby' => 'meta_value_num',
    'posts_per_page' => 4,
    'offset'=>'1'    //USE OFFSET PARAMETER
) );
//echo '<pre>';
//print_r($pages);  //Retrieve post lists
echo $post_id = $pages->ID ;
echo $post_thumbnail_id = get_post_thumbnail_id( $post_id )