I have added many blog posts in wordpress from the admin panel, but now i have to get date of the all inserted blog posts. i have used the get_the_date(), but this function return me of just first blog post, not the date of other blog posts, and i have also used the the_time(), this function also return me the time of only first blog post, how i will be able to get date of the all blog posts?


If you want to get the dates of all blog posts then you'll need to perform your own query and loop that.

This is the query:

$posts = new WP_Query(array(
    'post_type' => 'post',
    'posts_per_page' => -1

Now you'll need to loop those posts like so:

if( $posts->have_posts() ) : while( $posts->have_posts() ) : $posts->the_post();
    echo get_the_date();
endwhile; endif;

If you have 50 posts then you'll see 50 dates.

If you need to make your query more specific to filter out certain posts then you can find all of the possible parameters with many code examples here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.