-
Author
-
September 1, 2017 at 14:30 #172312lopregParticipant
Please, how can I show Last Modified date to tell readers and search engine bots when a content on my site was last updated?
I will like to show something like “Last Updated: September 1, 2017” , in place of the actual publication date, as can be seen on the image below.
Attachments:
You must be logged in to view attached files.September 2, 2017 at 16:19 #172395Kieran_SQModeratorHi,
Thanks for contacting us today, I’ve looked into your question and you’ll either need to do a lot of child theme customizations or use some sitewide code. The latter options is probably the best, please have a look at this article posted by WPbeginner on August 30th 2017 http://www.wpbeginner.com/wp-tutorials/display-the-last-updated-date-of-your-posts-in-wordpress/.
They add the below code to the Child theme’s functions.php
COPY CODEfunction wpb_last_updated_date( $content ) { $u_time = get_the_time('U'); $u_modified_time = get_the_modified_time('U'); if ($u_modified_time >= $u_time + 86400) { $updated_date = get_the_modified_time('F jS, Y'); $updated_time = get_the_modified_time('h:i a'); $custom_content .= '<p class="last-updated">Last updated on '. $updated_date . ' at '. $updated_time .'</p>'; } $custom_content .= $content; return $custom_content; } add_filter( 'the_content', 'wpb_last_updated_date' );
You can use the below CSS class to style your element to suit your needs
COPY CODE.last-updated { }
Hope this helps,
Kieran.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionIf you like the theme or the support you've received please consider leaving us a review on Themeforest!
Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.
September 3, 2017 at 12:48 #172474lopregParticipantHello KieranSQ
I added the suggested code to the Child theme’s functions.php but the output was on Pages and not posts. Please, how can I make this work on Post pages only?
September 3, 2017 at 16:09 #172483Kieran_SQModeratorHi,
You do not appear to be using the post meta on your single posts, try enabling this to see if the above code works.
You can go to Theme Options > Blog > Scroll to: Meta settings to enable date meta for single posts
See here for example: https://www.campusportalng.com/education/post-utme-news-updates/27098/.
Thanks,
Kieran.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionIf you like the theme or the support you've received please consider leaving us a review on Themeforest!
Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.
September 3, 2017 at 23:41 #172548lopregParticipantHi KieranSQ
I had actually disabled Meta for only that particular post. I have re-enabled it now and the above code still does not work. Please, check again
September 3, 2017 at 23:50 #172550Kieran_SQModeratorOkay, I am going to ask my colleague @Radu look at this for you as this should work – they may well have better ideas on how to achieve this.
Please can you update the post with some login credentials, they’ll be in touch with you on Monday or Tuesday.
Thanks for your patience,
Kieran.
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionIf you like the theme or the support you've received please consider leaving us a review on Themeforest!
Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.
September 4, 2017 at 00:40 #172559lopregParticipantI have already attached the login credential to my last response. I will be waiting for their response then. Thanks
September 5, 2017 at 17:56 #172682RaduModeratorHi,
Revert back all of those changes/snippets and use this instead: https://pastebin.com/raw/k72fn2X7
Just copy that code to wp-content/themes/kleo-child/functions.php
NOTE: Child theme needs to be installed and activated.
The Last updated date will be displayed only on the post pages somewhere else the normal.
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Ticket solutionSeptember 6, 2017 at 15:54 #172758RaduModeratorYou’re welcome
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
The forum ‘General questions’ is closed to new topics and replies.