Support

Account

Home Forums Backend Issues (wp-admin) Cannot Query By Custom Field Reply To: Cannot Query By Custom Field

  • 
    $args = array(
    	  'post_type' => 'shop_order',
    	 'post_status' => 'any',
    	  'posts_per_page' => -1,
    	'meta_key'		=> 'recurring',
    	'meta_value'	=> 1
    	);
    
    // query
    $recurring= new WP_Query($args);
    if ($recurring->have_posts()) {
      $recurring->the_post();
    
      // code to show what you want from these posts
    
      wp_reset_postdata();
    }
    

    see the WP_Query examples here https://www.advancedcustomfields.com/resources/query-posts-custom-fields/