I know how to get the last or oldest post data using following code
$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 ?
I know how to get the last or oldest post data using following code
$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 ?
Share Improve this question asked Aug 1, 2018 at 8:29 topper1309topper1309 751 gold badge2 silver badges9 bronze badges 1 |1 Answer
Reset to default 3function is_first() {
global $post;
$loop = get_posts( 'numberposts=1&order=ASC' );
$first = $loop[0]->ID;
return ( $post->ID == $first ) ? true : false;
}
you can use this too
id
FROM {$wpdb->posts} WHEREpost_type
= 'post' ANDpost_status
= 'publish' ORDER BYpost_date
ASC"); – Trilok Commented Aug 1, 2018 at 8:43