How to display how much time ago a post was published?

Posted in: Newspaper
Post count: 77

I have tried various ways to make the published day be displayed in the format of “Published X time ago” but have failed. The most successful attempt so far was with the Meks Time Ago WP plugin, but then it only applied its effect on the posts pages; it did not have any effect in the home page.

I deactivated that and put the following code in the functions.php file, to no avail. Of course I deactivated the aforementioned plugin.

function my_post_time_ago_function() {
return sprintf( esc_html__( '%s ago', 'textdomain' ), human_time_diff(get_the_time ( 'U' ), current_time( 'timestamp' ) ) );
}
add_filter( 'the_time', 'my_post_time_ago_function' );

What am I missing here? Please elaborate.

Post count: 35449

Hi,
Unfortunately there is no option for this, you can achieve the hours ago on blocks only with custom work.
For this you can use this article -> https://mekshq.com/change-wordpress-date-format-to-time-ago/ or the official documentation -> https://developer.wordpress.org/reference/functions/human_time_diff/
There are also plugins that can be use for this -> https://wordpress.org/plugins/meks-time-ago/
If you want to use the “Time ago format” you need to use a single post template from tagDiv Cloud Library and edit it with tagDiv Composer click on single post date and enable the “Time ago format” -> https://www.screencast.com/t/2G5ogZnde0JZ
Thank you!

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newspaper’ is closed to new topics and replies.