Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › The date in printed in english, how to show it in the site language?
This topic contains 7 replies, has 2 voices, and was last updated by kyrian 2 months ago.
- AuthorPosts
- January 28, 2023 at 12:00 pm #41133
The date in printed in english, I cannot find a way to show it in the site language (italian) – https://accademiainfinita.it/2/contenuti/
Oxygen builder prints the date in the site language by default – https://accademiainfinita.it/2/contenuti/societa/la-sociocrazia-prendere-decisioni-ascoltando-tutti/
What should I do to correct this?
Thanks
January 28, 2023 at 12:11 pm #41134Apart from the language issue,
I’d like to convert the dates to human-readable formatI have used this code to make this change site wide, it works in all posts and pages but not for the search results
// Convert all dates to human-readable format function custom_time_ago() { return human_time_diff(get_the_time('U'), current_time('timestamp')) . ' fa'; } add_filter('the_time', 'custom_time_ago'); add_filter('get_the_date', 'custom_time_ago'); add_filter('the_modified_time', 'custom_time_ago');
January 29, 2023 at 10:04 am #41138Hi,
On my end the dates are displayed correctly in the correct language, the plugin requests the date from WordPress core with the default date format set on the wordpress dashboard.
You can either use this option for custom date formats, or a custom code to change the date field for the results:
Best,add_filter('asp_results', 'asp_custom_date_time'); function asp_custom_date_time($results) { foreach($results as $k=>&$r){ $r->date = human_time_diff(get_the_time('U', $r->id), current_time('timestamp')) . ' fa'; } return $results; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 29, 2023 at 12:23 pm #41140Thank you so much for providing the custom code!
I was able to solve the language issue as well.
Your support is legendary 🙂January 29, 2023 at 12:24 pm #41141You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 29, 2023 at 12:27 pm #41142There is a little issue with the code you provided.
When I sue it, the date is being showed also for taxonomies (tags and categories) listed in search results.
see: https://www.screencast.com/t/UJnJmsbKC4Flive site: https://accademiainfinita.it/2/contenuti/
How can I modify the code, so the date shows only for posts/pages?
Thanks
January 29, 2023 at 12:28 pm #41144Try:
Best,add_filter('asp_results', 'asp_custom_date_time'); function asp_custom_date_time($results) { foreach($results as $k=>&$r){ if ( isset($r->post_type) ) { $r->date = human_time_diff(get_the_time('U', $r->id), current_time('timestamp')) . ' fa'; } } return $results; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 29, 2023 at 12:31 pm #41145perfect, thank you 🙂
- AuthorPosts
You must be logged in to reply to this topic.