-
-
Save billerickson/4fb121ce8e025097da364c25adc70fe6 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Add Time to Display Posts Shortcode | |
* @link https://displayposts.com/2019/01/04/display-time-after-post-date/ | |
* | |
*/ | |
function be_display_posts_time( $output, $original_atts, $image, $title, $date, $excerpt, $inner_wrapper, $content, $class, $author, $category_display_text ) { | |
// Only run our code if include_time is set | |
if( empty( $original_atts['include_time'] ) ) | |
return $output; | |
$time = ' at ' . get_the_time( 'g:i a' ); | |
// Now let's rebuild the output and add the $time to it | |
$output = '<' . $inner_wrapper . ' class="' . implode( ' ', $class ) . '">' . $image . $title . $date . $time . $author . $category_display_text . $excerpt . $content . '</' . $inner_wrapper . '>'; | |
// Finally we'll return the modified output | |
return $output; | |
} | |
add_filter( 'display_posts_shortcode_output', 'be_display_posts_time', 10, 11 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment