Created
February 16, 2017 08:20
-
-
Save michaelwilhelmsen/4877ee9dd1a84f96df35a5ab8b76d673 to your computer and use it in GitHub Desktop.
Add Last-Modified headers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action('template_redirect', 'sp_add_last_modified_header'); | |
| function sp_add_last_modified_header($headers) { | |
| //Check if we are in a single post of any type (archive pages has not modified date) | |
| if( is_singular() ) { | |
| $post_id = get_queried_object_id(); | |
| if( $post_id ) { | |
| header("Last-Modified: " . get_the_modified_time("D, d M Y H:i:s", $post_id) ); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment