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 tax_query
    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(
                '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.