Is it possible to add relation between meta_query and tax_query?

Question

I have custom post type with some ACF fields. I use ACF for extra properties of entity, and I use native wordpress taxonomies too for base category of entity. So I need to build query with meta_query and tax_query same time. It looks like:

WP_Query {
  "meta_query" => {
    "relation" => "OR",
    [
      "key" => "rating",
      "compare" => "LIKE",
      "value" => "AA"
    ]
  },

  "tax_query" => {
    "relation" => "OR",
    [
      "taxonomy" =>"currencies",
      "field" =>"slug",
      "terms" => [
        "eur",
        "usd"
      ],
      "operator" => "IN"
    ]
  }
}

If I searching only by taxonomies or only by meta-fields, all works fine. But how searching by taxonomies OR by meta-fields (by default, WordPress use AND relation, i.e. post will finded only if all sub-queries will return true)? I.e. I need add relation between two type of queries in main WP_Query object.

Any suggestions?

0
, , Raymond 4 years 2017-10-13T07:32:32-05:00 0 Answers 94 views 0

Leave an answer

Browse
Browse