Support

Account

Home Forums General Issues Custom query for post and postmeta values Reply To: Custom query for post and postmeta values

  • If I understood correctly you can try this. Just insert each field as array line after ‘relation’ and when use wp_query loop.

    $searchkey = 'yourwordhere';
    $args = array(
      'post_type'=> 'cpt_title',
      'posts_per_page' => -1,
      'meta_query' => array(
      'relation' => 'OR',
       array('key' => 'acf_field_name_here1','value' => $searchkey,'compare' => 'LIKE'),
       array('key' => 'acf_field_name_here2','value' => $searchkey,'compare' => 'LIKE')
       )    
    );
    
    $wp_query = new WP_Query($args);
    ?>