Is there any way to show the date that the last post (most recent) from my custom post type was created?

I want to have my site show the last time a list of products was updated and i figured that it could be based on when the last post was created, or modified. is this possible?

  • If you don't like the question, why not explain why so the OP can learn for next time?
    – Steven
    Jun 1, 2016 at 9:27
  • why the downvote?
    – rudtek
    Jun 2, 2016 at 16:56

2 Answers 2


Based on what you're asking and what I am understanding there is the_modified_date() or if you just want the value get_the_modified_date().

If you ever want the creation date you could use post_date and post_date_gmt. Several questions on this:

If you are asking for a complete solution I would encourage you to search under custom post type and wp_query. We have several questions that are on the topic. If can make an edit with code I do not mind trying to help you further.


You need a custom query for that. Basically, just a query that pulls 1 result from the posts table where the post type is your custom post type:

global $wpdb;

// the name you gave to your custom post type
$post_type = 'my_custom_post_type';

// this is the query string that we'll use with the $wpdb class
// selecting from the posts table where the post_type is your custom post type
// ordered DESC and LIMITed to 1 to get on the most recent entry
$query_str = "SELECT * from " . $wpdb -> prefix . "posts WHERE post_type = %s ORDER BY post_date DESC LIMIT 1";

// it's good practice to $wpdb -> prepare queries to the database
$results = $wpdb -> get_results( $wpdb -> prepare( $query_str, $post_type ) );

I've used get_results so you have your choice of which date (created or modified) you want to use

  • this works too! thanks. i went with the wp-query only because i'm more familiar with it, but i tried this and it seems to do the same process in a different manner.
    – rudtek
    Jun 2, 2016 at 16:57

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.