0

i want to get the latest date of post in the homepage of my site. in this code :

the_modified_date('d F Y');

date is different in different pages (For example page 1,2,...). i want to show just the date of latest post that published. thanks.

2 Answers 2

1

you can use get_the_date('d F Y');

0

The last published post date is:

$last_post_date = get_lastpostdate( 'blog', 'post' );

and the last modified post date is

$last_post_modified = get_lastpostmodified( 'blog', 'post' );

Here we use the 'post' post type and the 'blog' for the timezone.

Check out the documentation on get_lastpostdate and get_lastpostmodified for more info.

2
  • how can i do this with sql query.i dont want to use wordpress functions.and i want to get the date and convert to persian calendar.
    – Mehdi
    Commented May 5, 2017 at 7:26
  • Please edit your question with all relevant info to avoid guesswork. I don't understand why you don't want to use the WordPress API that even supports object caching? @Mehdi
    – birgire
    Commented May 5, 2017 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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