Support

Account

Home Forums ACF PRO Check if any choices is selected of a checkbox Reply To: Check if any choices is selected of a checkbox

  • You have to do a WP_Query to get posts using a meta query, if you are just looking to see if any if it is checked anywhere then you could limit the query to return one ID

    
    $args = array(
      'post_type' => 'your post type',
      'post_status' => 'pubish',
      'posts_per_page' => 1,
      'fields' => 'ids',
      'no_found_rows' => true,
      'meta_query' => array(
        array(
          'key' => 'checkbox field name',
          'value' => '"'.$field_value_to_find.'"',
          'compare' => 'LIKE'
        )
      ),
    )
    $my_query = new WP_Qeury($args);
    if (!empty($my_query->posts)) {
      // there is a post with this value checked
    }