Stumbled upon this ridiculous issue.
Consider the following simplified code:
$args = array( 'post_type' => 'project', ); $args['tax_query'] = array(array( 'taxonomy' => $_GET['tax'], 'field' => 'id', 'terms' => $_GET['term_id'] )); $custom_wp_query = new \WP_Query($args); var_dump($custom_wp_query->get_posts());
With WPML, this code works and returns the posts from the specified taxonomy and term. But only if it’s the default language. Other languages return nothing.
Fix?
$args['tax_query'] = array(array( 'taxonomy' => $_GET['tax'], 'field' => 'id', 'terms' => array($_GET['term_id']) // this must be an array.. ));
..even though Codex says ‘terms’ can be int, string or array 🙁