Forums Forums Search & Filter Pro Default Order Meta Value issue

Tagged: , , ,

Viewing 4 posts - 1 through 4 (of 4 total)
  • Anonymous
    #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
    #37198

    Hey 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
    #37259

    Gotcha! 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
    #37304

    Fantastic glad you got a work around sorted 🙂

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