When looking at a draft post, get_the_date()
only seems to return today’s date, not the post date, even if I have selected another date on the post edit screen.
Is there a way to show the “actual” post date, the one I selected?
I can see in the MySQL database that it’s saved in the post_date column. But, like get_the_date, $post->post_date
doesn’t return it. If the post is a draft, it shows the current date and time.
4 Answers
Yes, as you – so far – have no publish date.
You could use $post->post_modified
, which will always be the date of the latest modification to the post data.
Debug:
Try hooking into the filter and dump both vars:
function date_dump_callback( $date, $d )
{
echo '<pre>'; print_r( $date ); print_r( $d ); echo '</pre>';
return $date;
}
add_filter( 'get_the_date', 'date_dump_callback', 20, 2 );