The date in printed in english, how to show it in the site language?

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 kyrian 1 year, 1 month ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #41133
    kyrian
    kyrian
    Participant

    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

    #41134
    kyrian
    kyrian
    Participant

    Apart from the language issue,
    I’d like to convert the dates to human-readable format

    I 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');
    #41138
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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:

    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;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #41140
    kyrian
    kyrian
    Participant

    Thank you so much for providing the custom code!
    I was able to solve the language issue as well.
    Your support is legendary 🙂

    #41141
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #41142
    kyrian
    kyrian
    Participant

    There 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/UJnJmsbKC4F

    live site: https://accademiainfinita.it/2/contenuti/

    How can I modify the code, so the date shows only for posts/pages?

    Thanks

    • This reply was modified 1 year, 1 month ago by kyrian .
    #41144
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Try:

    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;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #41145
    kyrian
    kyrian
    Participant

    perfect, thank you 🙂

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.