Home › Forums › Front-end Issues › WP_query to order by custom field › Reply To: WP_query to order by custom field
If your figures connected to taxonomies, then you can filter by
Your query has to look like this:
// filter on figures from serie's taxonomy $args = array( 'post_type' => 'figure', 'posts_per_page' => -1, 'meta_key' => 'release_date_fr', 'orderby' => 'meta_value', 'order' => 'DESC', 'tax_query' => array( array( 'taxonomy' => 'serie', // taxonomy name 'field' => 'slug', // term_id, slug or name 'terms' => array( 'the-legend-of-zelda', 'hyrule-warriors' ), // single value or array of term id(s), term slug(s) or term name(s) ) ) ); // query the figures $the_query = new WP_Query($args);
BTW: If there is a error 500, then there is a new entry in you error logs, with more details about the error. Always start at this point to look for a solution.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We’re hard at work on ACF 6.1, and Beta 1 is now available 🚀— Advanced Custom Fields (@wp_acf) March 16, 2023
This release includes custom post type and taxonomy registration, an improved experience when selecting field types, PHP 8.1 and 8.2 compatibility, and more!
Let’s take a look 🧵https://t.co/Y0WcAT11l4
© 2023 Advanced Custom Fields.