该站点在其响应中不发送Last-Modified头。
我知道我应该在header("Last-Modified: " . the_modified_date());
之类的地方插入,但在哪里?
“ Last Modified” WordPress插件为我工作。http://wordpress.org/extend/plugins/header-last-modified/
它需要更改wp-includes / template-loader.php,因此在更新WordPress核心时要小心。
这在所有帖子上都对我有用-添加到主题functions.php文件中:
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');
}
}
编辑wp-config.php将其插入文件末尾吗?>