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.

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       .= '<span class="posted-on">';
	$output       .= '<span class="post-updated" itemprop="dateModified"> ' . $modified_on . '</span>';
	$output       .= '</span>';
	return $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.

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

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 meta data.

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”.

How to Display Last Updated Date using Astra Theme and Elementor 1

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.

  •  
  •  
  •  
  •  
  •  
  •  
If you liked this post, you should also read:

Share the WordPress love!

Share on facebook
Share on twitter
Share on reddit
Share on pinterest

Get Updates When We Update

Our newsletters contain loads of WordPress goodness guaranteed to whet your appetite for lip-smacking WordPress tips and treats.

Leave a Comment

Thank you for leaving your valuable feedback. Please do not use keyword in the name field. Let's have a meaningful discussion.

Scroll to Top

Get 99% OFF on all WPX Hosting monthly plans. Black Friday deal!

Get access to our WordPress Vault that contains the ultimate guides on WordPress security, optimization, beginner tips and much more to help you manage your WordPress site like a Pro.