Aleš Sýkora / November 28, 2023 / 4 comments
Order posts by ACF field in Oxygen Advanced query
1 min read / Oxygen Builder, Plugins, WordPress / Share on: Twitter, LinkedIn, Facebook
Post summary: If you need filter your advanced query by ACF field, you need to use the field as a meta_key and then order by meta_value. You can set it up in Advanced query builder in Oxygen builder like this:
If you need filter your advanced query by ACF field, you need to use the field as a meta_key and then order by meta_value. You can set it up in Advanced query builder in Oxygen builder like this:
$the_query = new WP_Query($myquery(
'post_type' => 'post_type_slug',
'posts_per_page' => -1,
'meta_key' => 'acf_field_slug',
'orderby' => 'meta_value',
'order' => 'DESC', // or ASC
));
Fuel my passion for writing with a beer🍺
Your support not only makes me drunk but also greatly motivates me to continue creating content that helps. Cheers to more discoveries and shared success. 🍻
Julian
Does this work the same for Metabox in Oxygen Advanced Query Builder?
Tomáš
May I ask you for a help with more advanced query? Thanks :)
Aleš Sýkora
Try it and let us know :) I don’t use metabox, but principle should me same.
Aleš Sýkora
Hey Tomáš, which query you need?