I am using a plugin which calls some posts grouped from a tag into another post. I want to add human_time to these posts, but the method I’ve used below just calls the time for the parent post.
if ($date) {
$output .= __('on ', 'posts-by-tag');
$output .= mysql2date(get_option('date_format'), $post->post_date) . ' at ' ;
$output .= mysql2date(get_option('time_format'), $post->post_date) . '<span class="the-times">' ;
$output .= human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago</span></p></div>' ;
The two middle outputs work properly, just the last one doesn’t. What would be the required changes on that last output to get it to work? I’m guessing it’s something to do with $post-> but I’m not sure of the right structure.
If this isn’t in “The Loop” you’ll have to target the post id in your
get_the_timefunction like: