The Black Friday & Cyber Monday 2021 is here !!! Grab Exclusive Deals - Shop More, Pay Less Get Now

How to Add Last Updated Date in Astra Theme?

In this tutorial, we are going to add last updated date in Astra Theme with the help of code inserted into functions.php.

You can also use several last updated date-related plugins. Here we are going to use the child theme method or use the code snippets plugin to insert code in functions.php. Along with it, I am going to test the plugin method too.

In this guide, you will also learn to

  • Use the last updated date in Child Theme.
  • Use the Code Snippets to insert code.
  • Display updated date without plugin.
  • Use plugin to show updated date.
  • So on…
Add Last Updated Date in Astra Theme

Why Last Updated Date in Astra Theme?

Google loves to answer actually users’ queries and it constantly tries to improve SERPs through its algorithm update. It’s always important to produce high-quality content if you want Google to love your site.

Google loves fresh content and fresh content doesn’t always have to be a new blog post or page rather it can be old content that is updated making relevant changes.

Showing last updated in SERPs with Astra Theme

Last Updated Date helps to show that

  • Your content is being updated reflecting to the latest changes to make it more fresh and relevant.
  • To let search engine to show the updated date in Search Engine Result Pages (SERPs).
  • So on..

Last Updated Data in Astra Without a Plugin

Showing updated date in Astra Theme is easy if you are using any version (free or pro) of Astra Theme.

Basically, in the pro version, you can activate the blog pro module if you want to get extra functionality but not compulsory.

Activating Blog Pro Module in Astra Theme

You need to enable Publish Date option through customizer, so follow this process.

  • Go to Appearance > Astra Options.
  • Now, visit Appearance > Customize > Blog.
  • Click on Single Post.
  • Under the Meta, Enable Publish Date option (you can also drag it up and down).
  • Also, enable/disable other meta option as required.
  • Hit Publish button.
Publish Date option in Astra Pro Theme

Now, you will be able to see the Published Date in a single post.

Now, if you have updated the post and want to show the last updated date then you have to add the following code in functions.php.

For this purpose, you can create & install Astra child Theme but do not add code to the main theme directly. You may lose all the modifications while making updates.

function astra_wplogout_post_date( $output ) {
	$output        = 'Last Updated On:';
	$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', 'astra_wplogout_post_date' );

so go to Appearance > Theme Editor> functions.php, Copy and Paste the following code, and Hit the Update File button.

If you haven’t created a child theme, then you can also insert code in functions.php via the Code Snippets plugin.

First, install the plugin, go to Snippets > Add New. Enter the Title, Copy and Paste the above code in the snippet box and Hit Activate button.

Now, you can see the result in a single post.

I am too using this plugin in my website too to add various code in functions.php. It is one of the safest ways to add the code so that you don’t mess with other code in that PHP file.

This is how you can show the last modified date on a blog post instead of the published date in Astra WordPress Theme.

Last Updated Data in Astra Theme using a Plugin

If you want to try out to show updated date in Astra Theme then another solution is using a plugin.

I don’t have any recommendations for the plugin since there are lots of plugins to show the last updated info. Here I am going to use WP Last Modified Info for demonstration purposes only, you can use anyone.

Install the plugin as you already know how to install & activate the plugin.

Before proceeding, this plugin adds modified info in a new line rather than replacing the default metadata in Astra Theme. so, disable the metadata from the customizer.

Go to Appearance > Customize > Blog > Single > Meta.

Disable Meta in Astra Theme

Now go to Settings > WP Last Modified Info, you will see various settings.

Under Post Options > Enable for Posts/Pages on Frontend option.

Now, you can see the updated date in the frontend.

If you want to enable the JSON-LD Schema Markup Mode in this plugin then go to the Schema menu option.

Using this plugin, you can show the published date and updated date at once using tags available under Post Options.

Other than this, you can also look out for the various settings in this plugin.

Also Make: Last Widget Sticky in Astra Theme

Final Outcome

If you are using the code method then you can now see the Last-Modified date on Astra Theme. This is the final outcome of the code.

Last Updated Date on Astra WordPress Theme

If you are using a plugin then the result will be like this

Last Updated Date using a Plugin

At the End

If you haven’t created a child theme then I recommended you add the last updated date in Astra Theme through the code snippets plugin as it is a simple and easy process.

I am using a similar method in my blog too. These days you don’t have to create a child theme unless you are going to customize it heavily.

So Finally?

Are you going to create a child theme or use the code snippets plugin to add codes in functions.php?

Either way, you can leave a comment below and also queries if you have any.

Share:

I am obsessed with WordPress and write articles about WordPress Speed Optimization, SEO, Blogging. I mostly publish tutorials on GeneratePress and GenerateBlocks.

Leave a Comment