I have a custom post type called ‘Skateboards’. Within the custom post type of ‘Skateboards’ , I added three checkboxes (filed type checkbox) with a field name of ‘skateboard_performance’ associated to the ’Skateboards’ custom post type via ACF. The values of the three check boxes are ‘Platinum’ , ‘Gold’ and ‘Silver ’.

What I am trying to accomplish is to display the ‘Skateboards’ post type in order of ‘Platinum’ , ‘Gold’ and ‘Silver’. So all of the Skateboards posts marked with ‘Platinum’ checkbox will display 1st. Followed by all Skateboards posts marked with ‘Gold’ checkbox to display 2nd and then all skateboards posts marked with ‘Silver’ to display 3rd.

Any ideas on what the $args to do that would look like?

So far i got up to here but I am having difficulty ordering them correctly :

$args = get_posts(array(
‘post_type’ => ‘skateboards’, //insert the correct post_type name
‘posts_per_page’ => -1,
‘meta_key’ => ‘skateboard_performance’, //sample acf field name
‘orderby’ => ‘meta_value’,
‘order’ => ‘ASC’

1 Answer 1


Given that this order you desire is unfortunately not alphabetical (although that wouldn't be very scaleable... but it would be handy). You might make life easier on yourself by adding another custom field called (say) "display_order". Then add the numbers 1,2 and 3 to that field, and then query the post type ordering by these values.

As far as I can see, it's that or running three separate queries to retrieve the three "levels" of board. Or some madder idea of retrieving them via one query into an array, and ordering that array as you require.

  • I like mayersdesign's suggestion and have done something similar when posts couldn't be sorted easily by title or a custom field, but another option (assuming you won't need to grow beyond "Platinum", "Gold", and "Silver") would be to simply grab all posts and then loop thru each using an if statement (so that if no Platinum then it skips right to Gold, etc.) and then foreach. If you anticipate adding more levels, this won't hold up well but should be simple to implement.
    – Trisha
    May 3, 2022 at 18:38
  • @Trisha - If you like it, why not upvote it? haha. Thanks May 24, 2022 at 14:57
  • thank you for the reminder, can't believe I missed that. :-)
    – Trisha
    May 25, 2022 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.