I run a WordPress site, and I’d like to print a dateline (ex: “July 22, 2020 at 1:05 p.m. EDT”) under the featured image at the top of each post, a time of the post’s initial publication.
Though datelines are common in news sites and blogs, my theme doesn’t present them as options, and if there’s a way to force them without switching themes, yeah, I’d love to find it. I’ve been grafting careful CSS onto this beast for longer than I care to admit and am more keen on putting my pride aside and asking for help than I am on starting fresh with another theme.
I know WordPress stores in a variable or array the posts’ “publishing dates” — even in my theme, these dates already appear beneath each post on the homepage.
So I know the data is there, and I’m aware that functions like “get_the_date()” exist, too.
What I can’t discern from all of the currently answered questions is what exactly the syntax would be for what I am describing, into what file (I presume ‘single.php’ but am unsure) I should be pasting that syntax, and once in that correct file, pasted where exactly.
Any help is greatly, greatly appreciated. Thank you, all.
Advertisement
Answer
The file single.php would be where you would start to look at which file is responsible for showing your posts. Sometimes they include files in other templates that you’ll have to locate. This depends on how your specific theme is setup.
When you find the file and where in that file you need to display the publication date. You can put this code to display the date in your format.
<?php echo get_the_date('F j, Y at g:i a'); ?> EDT