Last active
September 17, 2022 16:34
-
-
Save hearvox/bc5bfd9b36fd0f0322df99d5b13039ea to your computer and use it in GitHub Desktop.
WordPress Twenty Twenty theme custimizations, via custom plugin (e.g., mod date in post meta)
This file contains 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
<?php | |
/** | |
* Adds modified date to displayed post meta. | |
* | |
* Uses action in theme's /inc/template-tags.php file. | |
* Param values passed by the action hook. | |
* @param int $post_id The ID of the post. | |
* @param array $post_meta An array of post meta information. | |
* @param string $location The location where the meta is shown. | |
*/ | |
function my_mod_meta( $post_id, $post_meta, $location ) { | |
// If post was modified since publication. | |
if ( get_the_modified_time( 'U', $post_id ) > get_the_time( 'U', $post_id ) ) { | |
$has_meta = true; | |
?> // Add list item to post meta with mod date. | |
<li class="post-date meta-wrapper"> | |
<?php _e( 'Update: ', 'twentytwenty' ); ?> <time class="meta-text"><?php the_modified_time( get_option( 'date_format' ) ); ?></time> | |
</li> | |
<?php | |
} | |
} | |
add_action( 'twentytwenty_end_of_post_meta_list', 'my_mod_meta', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment