Home › Forums › Support › Want to show updated date in place of published on posts and google results
- This topic has 7 replies, 3 voices, and was last updated 1 year, 6 months ago by
Elvin.
-
AuthorPosts
-
December 7, 2020 at 4:27 am #1570209
Bryan
I am using a Marketer theme but there is no option to show the updated date of the post instead of the published date on the posts and google search results.
I am a newbie so if you are referring me to certain changes in the theme files kindly guide me.
December 7, 2020 at 4:37 am #1570221David
StaffCustomer SupportHi there,
it requires a little PHP Snippet to be added to your site.
This is the filter required for reference:https://docs.generatepress.com/article/generate_post_date_show_updated_only/
Options for adding PHP to your site is covered here in detail:
https://docs.generatepress.com/article/adding-php/
Quick snapshot of how to for that – there are two options:
Option 1. If you’re using a Child theme then copy the code provided ie:
add_filter( ‘generate_post_date_show_updated_only’, ‘__return_true’ );
And paste into your child themes functions.php file.
Option 2. If you’re not using a child theme then install the Code Snippets plugin:
https://en-ca.wordpress.org/plugins/code-snippets/
Once enabled Dashboard > Snippets > New.
Paste the code in there and save it. Leave all other settings as default.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/December 7, 2020 at 8:35 am #1570568Bryan
OK, I get it. Very nice explanation.
And it’s working. I installed a plugin code snippets then add the provided code here.
Next help I want that it replaces the published date but I want the text to appear like ‘Last updated on’ so please help me with that
December 7, 2020 at 11:36 am #1570728David
StaffCustomer SupportYou can add this snippet:
add_filter( 'generate_post_date_output','tu_add_to_post_date' ); function tu_add_to_post_date( $output ) { return '<span>Last updated: </span>' . $output; }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/December 8, 2020 at 10:11 am #1571904Bryan
First of all, thank you so much, David.
Secondly, will it show in the Google search results?
December 8, 2020 at 3:29 pm #1572146Elvin
StaffCustomer SupportSecondly, will it show in the Google search results?
It will but not immediately. Google bots will have to recrawl your site with the updated settings first.
You can ask Google to recrawl your site if you’re worried that it might take too long.
https://developers.google.com/search/docs/advanced/crawling/ask-google-to-recrawlA wise man once said:
"Have you cleared your cache?"December 9, 2020 at 2:55 am #1572552Bryan
Thank you so much. You guys are awesome.
December 9, 2020 at 2:57 am #1572554Elvin
StaffCustomer SupportThank you so much. You guys are awesome.
No problem. Glad to be of any help. 🙂
A wise man once said:
"Have you cleared your cache?" -
AuthorPosts
- You must be logged in to reply to this topic.