Forums › Forums › Search & Filter Pro › Default Order Meta Value issue
- This topic has 3 replies, 2 voices, and was last updated 8 years, 9 months ago by Ross.
-
Anonymous(Private) February 17, 2016 at 1:21 am #37175
I am trying to setup a default order by a meta value but having issues. Instead of it changing the ordering it’s actually filtering my results and ONLY showing the item that has the meta value I am ordering by. To explain….
I setup an ACF field called featured_resource. It’s a true/false field. I am selecting my Default Order to be “featured_resource” and “numerical” as my order. But upon doing this, as mentioned, it now only shows the items with this meta value.
Thank you for your assistance reviewing this!
NOTE: sorry accidentally first posted this yesterday in Feature Requests thread, please delete that one.
Ross Moderator(Private) February 17, 2016 at 12:14 pm #37198Hey Trevor
This is I’m afraid how ordering works.
We use the ordering functions provided by WP:
https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
And when ordering by a meta value, any post that does not have have that meta key will be excluded.
So, I guess you must add empty values for the post meta on all the posts that you want to show up :/
Thanks
Anonymous(Private) February 17, 2016 at 9:21 pm #37259Gotcha! Okay, well good news is with this info in hand I was able to get something easily figured out.
For anyone else looking to do something similar, I just used an ACF radio field instead with two options yes / no, and set the default value to ‘no’. That way there is a value for everything so they all show, but I orderby the Meta Value still so that my ‘yes’ items show first.
Thanks for the quick reply, great support as always!
Ross Moderator(Private) February 18, 2016 at 11:11 am #37304Fantastic glad you got a work around sorted 🙂
-
AuthorPosts