Archived topic
Add Time to post meta
5 replies · Started by Brian on January 15, 2020
I would like to add the time in the meta for a specific post was written when viewing that individual post. Like:
January 13, 2020 2:15PM by Brian Jones
Hi there,
Does this help?
https://gist.github.com/generatepress/8bc94ae43f67c40a077aefc8ec970fd0
Let me know :)
That is the snippet I have been looking at but it ends up showing "Updated on: by Robert Jones" - missing the actual date/time there.
Instead of using code, go to "Settings > General" and set your time format to something like this:
F j, Y g:i a
My settings already were set to that. I changed that function a little to this and it works fine now:
$time_string = sprintf( $time_string,
esc_attr( get_the_date() ),
esc_html( get_the_date() ),
esc_attr( get_the_time() ),
esc_html( get_the_time() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
Awesome, glad you got it working :)