Hi, am currently using cloud category template under my category pages, I would like to edit normal date display to time ago but i seem not to get the correct code. Any help wold be appreciated.
To display time ago like this https://wizimatic.com/category/entertainment/
$buffy .= ‘ – ‘. human_time_diff( get_the_time(‘U’, $this->post->ID), current_time(‘timestamp’) ) . ‘ ago’;
I used the above code and its displaying wrong time on posts under categories. All posts are showing to have been published 3 months ago which is wrong.
Hi,
For more details about the behavior of this function, please check the WordPress Codex from here -> https://codex.wordpress.org/Function_Reference/human_time_diff
Thanks for your understanding!
Can you correct my code please, https://prnt.sc/mpsx8v
$buffy .= ' '. ( get_the_time('U', $this->post->ID) > strtotime( "7 days ago" ))? human_time_diff( get_the_time('U', $this->post->ID), current_time('timestamp') ). ' ago' : $this->get_date();
My categories posts are showing wrong time, like posts published today are appearing to be 3 months ago.
https://prnt.sc/mpsyxq
Hi,
Please replace the get_date() function with the following one.
<?php $post_id = $this->post->ID;?>
<?php echo human_time_diff( get_the_time('U', $post_id), current_time('timestamp') ) . ' ago'; ?>
The result should look like this -> https://www.screencast.com/t/Lx5qZsxsJ
Thanks for your understanding!
The code you send me is for blocks, yet am talking about categories.
I have no issue with blocks/ modules as i have already set time ago on them.
As you can see on my previous reply I had send you illustrations and screenshots.
I need to display time ago on categories.
Hi dennis,
I have checked your category page and it seems that your time for your posts are looking well, as you can see here -> https://www.screencast.com/t/iSQNBnw6YeV I have made some tests on my localhost with that code and it seems to bring good results. Our category pages use modules and if the get_date() function is changed from that module which is called by the category pages, you should bring well results with the date. -> https://www.screencast.com/t/nTcpIn9eJMl If is not what you mean, please provide more details about this case, sorry! I’m here to assist you!
Hope this helps and we look forward to helping you!
Thank for your understanding!
Am getting tired coz am just repeating my self. And from my the chat above all is clear of what i want.
First i said am using cloud template which i guess the changes for cloud category should be done under td-cloud-library/includes/tdb_module.php (if am wrong correct me)
$buffy .= ‘ ‘. ( get_the_time(‘U’, $this->post->ID) > strtotime( “7 days ago” ))? human_time_diff( get_the_time(‘U’, $this->post->ID), current_time(‘timestamp’) ). ‘ ago’ : $this->get_date();
The code above is giving me wrong time, all posts are showing to be 3 months. I have told u to correct me or show me how i can go about it.
Hello,
Indeed there seems to be a problem with this modification on cloud library templates. Please note that we have only tested this code and found it to work on the standard templates. We have not made any testing on the cloud library templates/ the code seems to need a few more adjustments until it will work properly on cloud library templates as well. Unfortunately since we do not have a customization department, we cannot offer customization service at the moment. If you need this modification we recommend you hire a freelancer from trusted freelance websites like studio.envato.com
The theme support does not cover custom code modification as mentioned in our support policy here: https://forum.tagdiv.com/support-policy-2/
We do try however to help out where we can but if the modification becomes too time consuming, we will have to decline.
Thank you for your understanding and for your patience
Bogdan B