Forums › Forums › Search & Filter Pro › Ordering WP_Query by Ascending order
Tagged: ASC, ascending order, post ordering
- This topic has 4 replies, 2 voices, and was last updated 9 years, 7 months ago by
Anonymous.
-
Anonymous(Private) November 8, 2016 at 10:29 am #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,
NeilAnonymous(Private) November 8, 2016 at 12:33 pm #69191Ahh 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
-
AuthorPosts