Created
May 25, 2013 16:52
-
-
Save joemcgill/5649780 to your computer and use it in GitHub Desktop.
A custom post time function for WordPress that allows you to change the output for posts that are published today.
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
/** | |
* custom post time function | |
* | |
* @uses global $post, get_the_time() and get_the_date() | |
* @vars $d (for custom date formatting), $t (for custom time formatting) | |
* @returns $my_post_time | |
*/ | |
function my_post_time($d, $t) { | |
global $post; | |
if ( date('Yz') == get_the_time('Yz', $post->ID) ) { | |
$my_post_time = 'today at ' . get_the_time($t, $post->ID); | |
} else { | |
$my_post_time = 'on ' . get_the_date($d, $post->ID); | |
} | |
echo $my_post_time; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment