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 ?

1 Answer
1

function 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

Leave a Reply

Your email address will not be published. Required fields are marked *