Bootstrap Templates Bundle

Tuesday, December 25, 2012

how-to-display-time-ago-for-posts-and-comments/


Open functions.php file of your theme and paste following code and Save:
?
1
2
3
4
function time_ago( $type = 'post' ) {
    $d = 'comment' == $type ? 'get_comment_time' : 'get_post_time';
    return human_time_diff($d('U'), current_time('timestamp')) . " " . __('ago');
}
Now place the following snippet in either single.php or comments.php (wherever you want to show it) within loop.
?
1
<?php echo time_ago(); ?>

No comments:

Post a Comment

Wokiee React eCommerce Template