Default Order Meta Value issue

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)

Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.