Skip to content

Instantly share code, notes, and snippets.

@joemcgill
Created May 25, 2013 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joemcgill/5649780 to your computer and use it in GitHub Desktop.
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.
/**
* 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