As a blogger if you are regularly updating your blog posts to keep them fresh, it also becomes important to display the last updated date in the posts instead of the original publication date. This ensures the readers that the content is recently updated and hence is still valid. Besides this, Search engines such as Google also show this date in the search snippet. Now because you’re reading this, you’d be already familiar with the fact why the Modified Date should be shown, so let’s just skip to how to show it in WooThemes Canvas.
Creating a Shortcode to fetch the Last Modified Date
WooThemes Canvas makes use of the very powerful WooFramework and hence a lot of the work of the theme is handled by shortcodes which are created in the /includes/theme-shortcodes.php file. We will just amend the already created shortcode post_date to create a new function post_moddate which will use the WordPress’s modified _time function. To add this shortcode, insert the following code to the end of your /includes/theme-shortcodes.php just before the closing php tag (child theme is recommended).
You can then call this shortcode anywhere in your content and the modified date will be displayed there. But that is not a feasible option. The following part shows how to replace the default post published date of canvas with the modified date.
Replacing Published Time with Last Modified Time
In order to replace the default Published Time with the Lost Modified Time, we need to edit the /includes/theme-actions.php file (again, child theme recommended) and further edit the woo_post_meta function to replace the post_date shortcode with our earlier created post_moddate shortcode. The basic implementation will be to simply replace post_date at line 1730 with post_moddate. Else if you want to make it look a little better, just like it is done at TechMesto, replace the entire function code with the following code (i.e. replace from line 1712 till 1734)
Save the file when done. Your posts pages will now start showing the last updated date instead of the date when the post was first published.
Get weekly updates via email!
Thank you for subscribing.
Something went wrong.