vasvirshich
Forum Replies Created
Viewing 4 replies - 1 through 4 (of 4 total)
-
We want to see the post update date for single pages. And in the archives – the date the last post was updated.
It’s easier to make a hook that will allow you to override the sending of Last-modified headers.Thanks for the answer.
Is it possible to make the plugin change the date of creation of the cache file through the touch function in php, so that this particular date is then given in last-modified?Send to last-modified the time the post was created or modified
Just for example:/** * If posts, pages, custom post types */ if ( is_singular() ) { global $post; if ( ! isset($post->post_modified_gmt) ) { return; } $post_time = strtotime( $post->post_modified_gmt ); $modified_time = $post_time; /** * If we have comment set new modified date */ if ( (int) $post->comment_count > 0 ) { $comments = get_comments( array( 'post_id' => $post->ID, 'number' => '1', 'status' => 'approve', 'orderby' => 'comment_date_gmt', ) ); if ( ! empty($comments) && isset($comments[0]) ) { $comment_time = strtotime( $comments[0]->comment_date_gmt ); if ( $comment_time > $post_time ) { $modified_time = $comment_time; } } } $last_modified = str_replace('+0000', 'GMT', gmdate('r', $modified_time)); }We can modify cache.php to suit our needs. But when updating the plugin, the changes will be lost.
Maybe there is some way to avoid this?Here is an example post: https://www.spbmuzei.ru/samye-neobychnye-i-interesnye-mesta-peterburga
Viewing 4 replies - 1 through 4 (of 4 total)