Forums Forums Search & Filter Pro sort_order= custom field is not working

Viewing 9 posts - 1 through 9 (of 9 total)
  • Anonymous
    #120693

    Hi,
    I’m trying to add buttons where the user can order by Date, Price and another custom field.
    On this resultspage:
    http://wbr.ikon.be/te-huur/?_sfm_prijs=0+10000&_sfm_slaapkamers=0+5

    So if I want to allow the user to sort the results by price (a custom field called ‘prijs’ in my case),
    I would add to the url this:
    http://wbr.ikon.be/te-huur/?_sfm_prijs=0+10000&_sfm_slaapkamers=0+5&sort_order=_sfm_prijs+desc+num
    But this gives 0 results.

    The same goes for any other custom field I try (num or alpha).
    I also tried using the ‘Sort Order’ field in the Search Filter UI and selecte sort by ‘Meta Value’ and then setting ‘prijs’ as the key, but the result is the same as here:
    http://wbr.ikon.be/te-huur/?_sfm_prijs=0+10000&_sfm_slaapkamers=0+5&sort_order=_sfm_prijs+desc+num

    So these are custom post types with custom fields (ACF PRO)

    (The default sorting does work; by ID and date etc).

    Thanks in advance

    Trevor
    #120700

    And yet this gives results:

    http://wbr.ikon.be/te-huur/?_sfm_prijs=0+10000&_sfm_slaapkamers=0+5&sort_order=_sfm_prijs+num+desc

    But not sorted. Is there something wrong with the data in one or more posts for that field?

    Anonymous
    #120728
    This reply has been marked as private.
    Anonymous
    #120730

    So none of the custom fields are ‘sortable’. Like ‘slaapkamers’ (bedrooms) for example:
    http://wbr.ikon.be/te-huur/?sort_order=_sfm_slaapkamers+num+asc

    This is the WP query where the search filter arguments are added to:

    
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	$args = array(
    		'order'=> 'ASC',
    		'orderby' => 'date',
    		'post_type' => 'panden', 
    		'posts_per_page' => 9,
    		'meta_key' => 'status',
    		'meta_value' => array('Te huur', 'Te huur onder reservatie'),
    	        'paged' => $paged);
    	$args['search_filter_id'] = 71;
    	$pandenLoop = new WP_Query($args);
    
    Trevor
    #120732

    The better way to test if it is sorting properly is to make a test search and test page and use the shortcode results method. No special queries and less potential conflict with other things. The results will look not so good (visually) maybe but it is a reliable base to test from.

    Anonymous
    #120738

    I’ll do that first. Thanks!

    Anonymous
    #120742

    Using shortcodes it does work.
    http://wbr.ikon.be/test-results/?sort_order=_sfm_prijs+desc+num

    Doesn’t work when i use ‘custom’ or ‘archive’ for the results page.

    I guess it means I have to customize the /templates/results.php file in the plugin.
    Can I override this in my theme maybe?

    Trevor
    #120744

    So, if the shortcode method works, and plugins do not change, it is the theme, or the template file.

    You can considerably customize the results.php file. The documentation tells you how to copy the file from our plugin template folder, then you can edit it. I have placed examples of different ones in many threads here.

    Anonymous
    #120746

    ok thanks I will try that.

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