Reputation: 255
This is my code:
add_filter('the_modified_time', 'dy');
function dy() {
$time = get_the_modified_time();
$mytimestamp = sprintf(__('%s ago'), human_time_diff($time));
return $mytimestamp;
}
It does not work as I would like. What I am doing wrong?
Any help is appreciated.
Upvotes: 0
Views: 569
Reputation: 9549
Your filter only affects the the_modified_time()
function. It could be that your theme is displaying post times with a different time function. Try using the following.
add_filter('get_the_modified_time', 'dy');
add_filter('get_the_modified_date', 'dy');
add_filter('get_the_date', 'dy');
add_filter('the_date', 'dy');
add_filter('get_the_time', 'dy');
add_filter('the_time', 'dy');
function dy() {
$time = strtotime(get_post()->post_date);
$time_ago = human_time_diff($time, current_time('timestamp'));
return sprintf(__('%s ago'), $time_ago);
}
Upvotes: 2