获取上次或最早发布日期的最快方法-WP查询

时间:2018-08-01 作者:topper1309

我知道如何使用以下代码获取最后或最旧的post数据

$posts = get_posts(array(
  \'post_type\' => \'post\',
  \'order_by\' => \'publish_date\',
  \'order\' => \'ASC\'
));

And then I will get the date from the first array itself, but is there any quickest way to get that ?

1 个回复
SO网友:Adarsh

function is_first() {
    global $post;
    $loop = get_posts( \'numberposts=1&order=ASC\' );
    $first = $loop[0]->ID; 
    return ( $post->ID == $first ) ? true : false;
} 
你也可以用这个

结束