• Resolved Lai Xuancheng

    (@lai32290)


    I have two WP_Query like these:

    Searching by s:

    $query1 = new WP_Query([
      'post_type' => 'product',
      's' => $searchStr
    ]);

    and searching by metabox:

    $query2 = new WP_Query([
      'post_type' => 'product',
      'meta_query' => [
        [
          'key' => 'my_meta_key',
          'value' => $searchStr,
          'compare' => 'LIKE'
        ]
      ]
    ]);

    How can I create a query to relate these two query by “OR”, like:

    `$query1 OR $query2″ ?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to combine two or more WP_Query?’ is closed to new replies.