Code Runs in Child Theme, but not Code Snippets
-
The following code that aligns the last modifed date with published date runs in a child theme, but not in Code Snippets. Any idea how to fix?
<?php // Hook into the 'the_modified_date' filter for posts add_filter( 'the_modified_date', 'wpse_modified_date', 10, 2 ); // Hook into the 'the_time' filter for pages add_filter( 'the_time', 'wpse_modified_date', 10, 2 ); /** * Replace the published date with the last modified date. * * @param string $the_modified_date The current date string. * @param string $date_format The date format. * @return string The modified date string. */ function wpse_modified_date( $the_modified_date, $date_format ) { // Get the post object $post = get_post(); // Get the last modified date $modified_date = get_the_modified_date( $date_format, $post ); // Replace the published date with the modified date return $modified_date; } ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Code Runs in Child Theme, but not Code Snippets’ is closed to new replies.