How to insert Last-Modified HTTP-header in Wordpress?
The site doesn't send Last-Modified header in its response.
I know I should insert somewhere something like header("Last-Modified: " . the_modified_date());
bu开发者_如何转开发t where?
The "Last Modified" WordPress plugin works for me. http://wordpress.org/extend/plugins/header-last-modified/
It requires a change in wp-includes/template-loader.php so be careful when updating the WordPress core.
This worked for me on all posts - added into theme functions.php file:
add_action('template_redirect', 'theme_add_last_modified_header');
function theme_add_last_modified_header($headers) {
global $post;
if(isset($post) && isset($post->post_modified)){
$post_mod_date=date("D, d M Y H:i:s",strtotime($post->post_modified));
header('Last-Modified: '.$post_mod_date.' GMT');
}
}
Edit wp-config.php insert it at end of file before ?>
精彩评论