How to Display Last Updated Date using Astra Theme and Elementor

WordPress, by default, displays the published date of your posts. But as we know, for SEO purposes, the last updated date or modified date of your posts is more relevant than the published date. Also, the last updated date gives a fresh feel to your content that you may have written a long time back but have recently updated it.

So if you want to display the last updated date instead of the published date, how do you do this? This simple tutorial explains how you can display the modified date of your posts instead of the published date using the Astra theme and Elementor page builder on your WordPress site.

Of course, you do not need the Elementor plugin to display the last updated date, but I am listing the steps to show the last updated date on Elementor in case you’re using this popular and highly useful plugin.

I am assuming you’re already using the lightweight Astra theme for the purpose of this tutorial.

Display Last Updated Date in Astra Theme

Before proceeding further, I advise you to create and install the Astra Child theme using the Child Theme Generator. This is because you will need to paste some code in the theme’s Functions.php file and if you paste the code in the parent theme’s PHP file, any future theme update will override the code you have inserted and you will need to repeat the process over again.

This Astra theme review reveals why it’s the best multipurpose WordPress theme around.

So it is always better to use a child theme instead of making changes to the parent theme.

Just install the Astra child theme normally from within the Appearance>Themes settings and activate it. Then copy and paste the following code into the child themes Functions.php file. This file is usually located in the following directory: public_html/wp-content/themes/astra-child.

/**
 * Display only last modified date in the post metadata.
 *
 * @param String $output Markup for the last modified date.
 * @return void
 */
function your_prefix_post_date( $output ) {
	$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
	);
	$output       .= '';
	$output       .= ' ' . $modified_on . '';
	$output       .= '';
	return 'Updated on' .$output;
}
add_filter( 'astra_post_date', 'your_prefix_post_date' );

Remember to insert the code at the very end in the functions.php file of the Astra Child Theme and save the changes.

Your post meta will display the modified date with the prefix ‘Updated on‘ as you can see on this page. You can add your desired words in place of ‘Updated on’ in the third line from the end in the above snippet. What’s more, you can even remove the ‘Updated on ‘ comment entirely if you wish to display the last modified date without any prefix.

That’s it. The post meta will now show the “last updated” or “last modified” date in place of the published date.

ad

How to Display the Last Updated Date in Elementor

Now if you’re also using the popular page builder Elementor, in combination with the Astra theme, the post created with Elementor will still not display the last updated date even after making changes to the functions.php file.

Note: You will need Elementor Pro for making theme related changes like changes to the post metadata.

So to display the last updated date, head over to the Post template that you have created. In the meta data widget, choose “custom” from the Terms drop-down in place of “date”.

Next, in custom tab, select Post Date and then click on settings (the wrench icon) to the left of Post Date. Now in the Type tab, select “Post Modified” in place of “Post Published” and apply the changes.

The Elementor-created post will now show the Last Updated date in place of the published date.

Wasn’t that simple? If you found this tutorial useful, let me know in the comments below.

Further reading: 6 Stand-out WooCommerce Features in Astra Theme

Download the WordPress SEO eBook

Go from WordPress SEO Zero to Hero in no time. Also receive 2 Bonus PDFs with this free eBook.

Give it a try. You will thank yourself later.

About Trishan Mehta

Trishan Mehta is a WordPress fanatic since 2009. When not WordPressing, he is busy exploring hidden natural getaways whenever he can grab an opportunity. You can grab his WordPress SEO eBook to get up to speed with WordPress SEO.

4 thoughts on “How to Display Last Updated Date using Astra Theme and Elementor”

    • Hello Jonei,

      Google picks the date on your post. So even if you display the published date on your homepage or archives, it will not affect the modified date displayed on search results. You can even turn off the published date entirely from the Customizer settings.

      Reply
  1. hi, thanks for this, will elementor show this post date to every post we make with elementor? Or I have to change it manually

    Reply
    • Hi Sanaullah,
      Nice question. You should create a post template in Elementor and then apply the settings described here. This way, you will not need to apply it to individual posts.

      Reply

Leave a Comment