Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #223826

    Hello :-)
    I use 3 Easy Slider on my homepage.
    When i select a post, they are sorted alphabetically, but with more than 1 500 posts it’s a nightmare to find my latest post…
    Is there a way to change it? I would like this Select list show me my post sorted by date – the latestthe first in the list?

    — Request feature —
    Would be great to have a choice like :
    [x] by date
    [ ] by name

    Sort posts

    #224824

    Hi pako69!

    Please insert this code into the enfold/functions.php file:

    
                add_filter( 'avf_dropdown_post_query', 'avia_wpml_filter_dropdown_post_query_custom', 10, 4);
    
                function avia_wpml_filter_dropdown_post_query_custom($prepare_sql, $table_name, $limit, $element)
                {
                    if(defined('ICL_LANGUAGE_CODE'))
                    {
    			global $wpdb;
                    	$wpml_lang = ICL_LANGUAGE_CODE;
                    	$wpml_join = " INNER JOIN {$wpdb->prefix}icl_translations ON {$table_name}.ID = {$wpdb->prefix}icl_translations.element_id ";
                    	$wpml_where = " {$wpdb->prefix}icl_translations.language_code LIKE '{$wpml_lang}' AND ";
    
                    	$prepare_sql = "SELECT distinct ID, post_title FROM {$table_name} {$wpml_join} WHERE {$wpml_where} post_status = 'publish' AND post_type = '".$element['subtype']."' ORDER BY post_date ASC LIMIT {$limit}";
                    }
    		else
    		{
                    	$prepare_sql = "SELECT distinct ID, post_title FROM {$table_name} WHERE post_status = 'publish' AND post_type = '".$element['subtype']."' ORDER BY post_date ASC LIMIT {$limit}";
                    }
                    return $prepare_sql;
                }
    

    Best regards,
    Peter

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.