Hello,
I have Newspaper theme v6.5 installed on my website http://www.naukrinama.com
I want to add the following meta tag to my website as recommended by Google :
<meta http-equiv=”Last-Modified” content=”Saturday, 09 January, 2016 08:04:04PM”>
I want to add these onto the following pages :
a. Home Page
b. All Category Listing Pages
Now to add this I want the last Modified times for a dynamic page i.e. for the category page i want the time when the last post was added to that category or the category was modified and for the Home Page when was the last article or any change was being made on the whole website.
Please let me know how can this be achieved.
Hi,
and while you are at it, please explain how to get published time along the date, thanks!
Just found this: https://forum.tagdiv.com/topic/how-to-get-the-time-on-post-like-comment-and-category-or-date-and-tag-views/
Thats good for me!
Hi @rishab55555
You can use a plugin like https://wordpress.org/plugins/wp-last-modified/ but I am not sure how will work with the theme as it’s not tested. Also you can use a hook in functions.php file like this: http://screencast.com/t/241s2EYqQfn
add_action('wp_head','modified_time');
function modified_time() {
$output='<meta name="revised" content=' . get_the_modified_time() . '/>';
echo $output;
}
The result should be like here: http://screencast.com/t/lpyEudj97
If you want a different implementation you can check this links for more details: https://codex.wordpress.org/Plugin_API/Action_Reference/wp_head – https://codex.wordpress.org/Function_Reference/get_the_modified_time
Thanks!
-
This reply was modified 10 years by
Andrei L..
Hello Andrei,
Thanks for your revert !
I want to find out the last modified time of the pages like this :
1. Home Page – Last Modified time when any post was being added to the blocks shown on the home page or any change is made in page structure in backend. As home page is a dynamic page, how can this be found ?
2. Category Pages – Last modified time of a particular category page when any post was being added to this category or any changes was made in the category from wordpress backend. As category pages are dynamic pages how can be find the last modified time of these pages ?
3. Post Detail Pages – the last modified time for a post can be found out easily.
Also i want to add this meta tag in the header –
<meta http-equiv=”Last-Modified” content=”Saturday, 09 January, 2016 08:04:04PM”>
Let me know how can this be achieved.
Hello,
Also let me know how can i change the format of date/time of the given function to this format – Saturday, 09 January, 2016 08:04:04PM
Currently this function only returns the time ! I want both date and time in the above given format.
Hi
You need to add some conditions in the above code like here:
add_action('wp_head','modified_time');
function modified_time() {
if (is_front_page() or is_category() or is_single()){
$output='<meta name="revised" content=' . get_the_modified_time('Y/m/d g:i:s A') . '/>';
echo $output;
}
}
The result should be like here: http://screencast.com/t/mhdEeKGQNmeE
For more details about time format in WordPress please check this link: https://codex.wordpress.org/Formatting_Date_and_Time and change the parameters as you need.
Thanks!
-
This reply was modified 10 years by
Andrei L..
Hello Andrei,
Thanks for your revert !
I have got the timeformat modified. But it is showing incorrect date onto the homepage.
On the homepage i want to show the date of the last modified time of the whole site. But it is displaying some random old date, may be it is the date on which the homepage file was last modified.
Let me know how can I fetch the site last modified date on the home page.
Hi
Indeed the above code display the date when the actual page was last modified. To display the last modified date of the whole site you will need a different implementation and also many customizations in theme’s files. This is a complex task and unfortunately I can’t provide a solution now. If you need this and you’re not aware of the steps you need to take in this regard please consider hiring a developer or a freelancer to do this for you as we can’t offer customization services at the moment.
Thanks!