Display Posts includes a parameter for displaying the post date:
Shortcode
[display-posts include_date="true" posts_per_page="1"]
Result
- Display the current search results (7/30/2024)
Date Format
You can customize the date format to any format you like (see Formatting Date and Time). For instance, this will include the time along with the date:
Shortcode
[display-posts include_date="true" date_format="F j, Y g:ia" posts_per_page="1"]
Result
- Display the current search results July 30, 2024 5:54pm
Customize text around date and time
If you’d like to customize the text that appears before, between, or after the date and time, you’ll need to use the output filter.
In the below example, we are adding a new parameter for the time, and it includes “at” before the actual time is displayed.
Shortcode
[display-posts include_date="true" include_time="true" date_format="F j, Y" posts_per_page="1"]
Result
- Display the current search results July 30, 2024 at 5:54 pm
This code snippet goes in a core functionality plugin or Code Snippets.