|
↳ See all 14 articles
/ Documentation /Customizer Settings/Post Types (Blog)/ Show “Last Updated” or “Published Date” on Blog

Show “Last Updated” or “Published Date” on Blog

Do you want to enhance the presentation of your WordPress blog posts by displaying a clear indication of when they were last updated or published?

In this guide, we’ll walk you through the process of implementing this feature using the Astra theme.

Why Add a Last Updated or Published Date on Blog?

Clear communication with your audience is crucial, and providing information about when a post was last updated or published adds transparency to your content. It helps visitors understand the relevance and timeliness of the information they are reading.

How to Add Last Updated or Published Meta to Blog Posts

To implement this feature, make sure you have the Astra theme installed and activated on your website. Then, you can follow the steps below to add Last Updated or Published Text Message Before the Date.

  • Access your WordPress dashboard.
  • Navigate to Appearance > Customize > Post Types -> Single Post.
  • Click on the arrow next to Post Title.
  • Locate the Date module under Meta.
  • Click the arrow to choose between Published or Last Updated.
  • After selecting the option, save the changes.

Now, when you visit your blog post, you’ll notice the post metadata displays a Published or Last Updated date. This customization adds a valuable layer of information for your readers, improving their overall experience on your site.

You may follow a similar process and change the date type for Blog/Archive by navigating to Customize > Post Types > Blog/Archive.

Display Both Published and Last Updated Date

Using the available option in the Astra customizer, you can display either the Published or the Modified Date. If you want to display both Published and Last Updated or Modified Dates, you can follow the steps shared below:

  • Copy the code shared below and add it to the website using the functions.php file of the child theme.
// Display both Published and Last Modified date in Post meta data
function your_prefix_post_date2( $output ) {
	$format        = apply_filters( 'astra_post_date_format', '' );
	$modified_date = esc_html( get_the_modified_date( $format ) );
	$modified_on   = sprintf(
		esc_html( '%s' ),
		$modified_date
	);
	$updated_output = '';
	$separator = ' /';
	$separator = apply_filters( 'astra_post_meta_separator', $separator );
	$published_string = __('Published : ' , 'astra');
	$updated_string = __('' . $separator . ' Last updated : ' , 'astra' );
	$updated_output       .= '';
	$updated_output       .= ' ' . $modified_on . '';
	$updated_output       .= '';
	$modified_output = $published_string . $output . $updated_string . $updated_output;
	return $modified_output;
}
add_filter( 'astra_post_date', 'your_prefix_post_date2' );
  • If you don’t have your Child Theme installed, please check this article. If you are not sure how to add this code, please check this article.

Here is how it will appear once the above code is added to the website:

Display both Published and Last Updated Date

Important: The code used above will display the Published and Last Updated dates on Blog/Archive and Single Posts. If you wish to display it on either Blog/Archive or only the Single Posts, you can use the Site Builder module of Astra Pro to add the code to the website and apply the display conditions.

To do so, please follow the steps shared below:

  • Ensure the Astra Pro plugin is installed, and the Site Builder module is enabled.
  • Navigate to Astra > Site Builder > Create a Hooks layout.
  • Enable the Code Editor and add the above code in the PHP Syntax as shown below:
<?php
/* Add Your PHP Code here. */
?>
  • After that, select Hooks Action as wp_head and apply the display conditions to either Blog/Archive or Single Posts as required.
A sleek Astra theme logo for WordPress website customization.
  • Save the layout, and both the Published and Last Updated dates will appear on the page selected in the display conditions. For example, on the Single Posts, according to the display condition shown in the above screenshot.

Important: When the above code solution is used, the date customization options in the customizer may not work as expected. You may change the position of the date or disable it, but changing the format will not work. The changes need to be made to the code itself.

We hope this document has been helpful. If you have any questions or need support, feel free to contact us.

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
On this page
Want Faster Support?
Priority support within 2 hours
Best engineers to address you
Exclusive discounts on other products
Scroll to Top