Wordpress query posts by ACF of taxonomy of post (not ACF of post)

41 Views Asked by At

I was trying to filter posts, whose post_type = "edpost", whose slug of taxonomy "edpost-keyword" = HTTPS GET PARAMETER, and whose custom field "display" of taxonomy "edpost-keyword" = true. "display" is a custom true/false field of taxonomy "edpost-keyword". However, I am not able to find out how to filter posts by ACF of taxonomy of posts.

Here is my sample code, while it does not work.

function get_edpost_list($request) {
  $params = $request->get_query_params();

  $keyword = $params['keyword'];
  $args = array(
    'post_type' => 'edpost',
    'post_status' => 'publish draft',
    'paged' => $params['page'],
    'posts_per_page' => 12,
    'tax_query' => array(
      'relation' => 'AND',
      array(
        'taxonomy' => 'edpost-keyword',
        'field' => 'slug',
        'terms' => $keyword
      ),
      array(
        'taxonomy' => 'edpost-keyword',
        'field' => 'display',
        'terms' => true,
      )
    )
  );

  $query = new WP_Query($args);
}

Thanks a lot!

enter image description here

0

There are 0 best solutions below