Forums Forums Search & Filter Pro Ordering WP_Query by Ascending order

Viewing 5 posts - 1 through 5 (of 5 total)
  • Anonymous
    #69166

    Hey there

    I can’t quite get my WP_Query to order by ascending order – this is the original code I had before adding in Search & Filter – this worked fine and ordered my posts in ascending order but wasn’t yet being filtered;

    $queryPrice = new WP_Query(
    	array(
    		'orderby' => 'meta_value_num+0', 'meta_key' => 'price', 'order' => 'ASC',
    		's' => $_GET['s']
    	)
    );

    So this WP_Query needed to pick up my new Search & Filter terms so I replaced the standard search 's' => $_GET['s'] with the search & filter ID;

    $queryPrice = new WP_Query(
    	array(
    		'orderby' => 'meta_value_num+0', 'meta_key' => 'price', 'order' => 'ASC',
    		'search_filter_id' => 110
    	)
    );

    This now picks up the correct filtering of my posts but breaks the ordering – is there a way I can keep the correct filtering and order them in an ascending order?

    Regards,
    Neil

    Trevor
    #69184

    Did you set the results order in the S&F form (Posts tab)?

    Anonymous
    #69191

    Ahh yes that is what is setting it, I have changed this from descending to ascending so that’s the main thing I wanted.

    Out of curiosity can you overwrite this setting? For example having two loops on the page ‘highest price’ and ‘lowest price’ – where you’d toggle the visibility of each to see the desired loop you’re after.

    Hope that makes sense

    N

    Trevor
    #69210

    It does. I suspect that it might be possible, but only by hacking the plugin. At some point you may well add this feature. Is this thread now resolved and can it be closed?

    Anonymous
    #69212

    Yes that’s great – this is resolved, thank you!

    N

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