-
usethebitcoin
Hi,
I have copied the code from here https://generatepress.com/forums/topic/display-time-ago/ I placed it in function.php but the result was, not all of the date was change to time ago. What would be the problem about this?
Thank you.
-
Hi there,
Are you using this PHP code?
https://generatepress.com/forums/topic/display-time-ago/#post-452639If not, can you share your code?
Let me know 🙂
-
usethebitcoin
Hi Ying,
Yes this is my code.
function time_ago_date( $the_date ) { $time = human_time_diff( get_the_time('U'), current_time('timestamp') ); $updated = human_time_diff( get_the_modified_time('U'), current_time('timestamp') ); return sprintf( '%1$s Ago', $time, $updated ); } add_filter( 'get_the_date', 'time_ago_date', 10, 1 );
-
Alvind
Hi there,
Not sure if I missed something, but I just went through every single post on your site, and all the dates seem to be changed according to the format that you want.
Did you manage to fix it?
-
usethebitcoin
Hi Alvin,
Pls check this image here. https://i.postimg.cc/jj91Zq21/Screenshot-3.jpg
-
David
-
usethebitcoin
Hi David,
Actually its in the Crypto News Articles not in the CRYPTOCURRENCY GUIDE
https://i.postimg.cc/fbzy9tyk/Screenshot-3.jpg
Thank you
-
David
In your snippet, the end line:
add_filter( 'get_the_date', 'time_ago_date', 10, 1 );
Try changing the
10
to99
this will fire the filter later, and hopefully stop it from being overwritten. -
usethebitcoin
Hi David,
Thank for this one, this is a big help!
-
You’re welcome
- You must be logged in to reply to this topic.