title: Trying show list of cities
body: <p>First of all, sorry my horrible English =)</p>
  
  <p>I'll try to explain how works everything:</p>
  
  <p>I use this to create 'agreement' to be searched on my website, só the basic is the name, and where that 'agreement' works, for example, states and cities...  but I have a problem when I try to select the 'states' and after show the cities to select where my 'agreement' can be used and save to show on the site. 
  But when I select the states, the WordPress just don't show the cities, and this problem happened after some att in WordPress plugins (exemple: Advanced custom field) </p>
  
  <p>And know I have no idea how I can fix this.</p>
  
  <p>Here is my code: </p>
  
  <pre><code>//Load cities - Convenio
  
  function ag_apcef_load_cities_field_choices( $field ) {
      // get selected
      $selected = get_field( 'ag-estado-convenio', $post-&gt;ID );
      // reset choices
      $field['choices'] = array();
  
  
      if($selected) {
          $args = array(
              'post_type' =&gt; 'cities',
              'orderby' =&gt; 'title',
              'order' =&gt; 'ASC',
              'posts_per_page' =&gt; -1,
              'meta_query' =&gt; array(
                  array(
                     'key'     =&gt; 'city_meta_box_state',
                     'value'   =&gt; $selected-&gt;ID
                  )
              )
          );
  
          $posts = get_posts( $args );
          foreach($posts as $post) {
              $field['choices'][$post-&gt;ID] = $post-&gt;post_title;
          }
      }
  
      return $field;
  }
  add_filter('acf/load_field/name=ag-cidade-convenio', 'ag_apcef_load_cities_field_choices');
  
  
   // Admin enqueue - Convenio
  
  function ag_apcef_admin_convenio_enqueue( $hook ) {
      // Allowed post types
      $types = array( 'convenio' );
  
      if( !in_array( get_post_type(), $types ) )
          return;
  
      wp_enqueue_script( 'populate-area', get_stylesheet_directory_uri() . '/js/autopopulate-admin.js' );
  
      wp_localize_script( 'populate-area', 'populate_vars', 
          array(
              'populate_nonce' =&gt; wp_create_nonce( 'populate_nonce' ), // Create nonce
          )
      );
  }
  add_action( 'admin_enqueue_scripts', 'ag_apcef_admin_convenio_enqueue' );
  
  
   //Enqueue - Convenio
  
  function ag_apcef_convenio_enqueue() {
    if ( is_page( 'portal-de-vantagens' ) || is_page( 'bem-estar' )) {
      wp_enqueue_script( 'populate-area', get_stylesheet_directory_uri() . '/js/autopopulate.js' );
  
      wp_localize_script( 'populate-area', 'populate_vars', 
          array(
              'populate_nonce' =&gt; wp_create_nonce( 'populate_nonce' ), // Create nonce
              'ajaxurl' =&gt; admin_url( 'admin-ajax.php' )
          )
      );
    }
  }
  add_action( 'wp_enqueue_scripts', 'ag_apcef_convenio_enqueue' );
  
  
   //  Load cities by state
  
  function ag_apcef_city_by_state( $selected_state ) {
      // Verify nonce
      if( !isset( $_POST['populate_nonce'] ) || !wp_verify_nonce( $_POST['populate_nonce'], 'populate_nonce' ) )
          die('Permission denied');
  
      // Get selected state
      $selected_state = $_POST['state'];
  
      // Populate arr_data
      $arr_data = array();
      if(!empty($selected_state)) {
          $args = array(
              'post_type' =&gt; 'cities',
              'orderby' =&gt; 'title',
              'order' =&gt; 'ASC',
              'posts_per_page' =&gt; -1,
              'meta_query' =&gt; array(
                  array(
                     'key'     =&gt; 'city_meta_box_state',
                     'value'   =&gt; $selected_state
                  )
              )
          );
  
          $posts = get_posts( $args );
          foreach($posts as $post) {
              $arr_data[] = [
                  'key' =&gt; $post-&gt;ID,
                  'value' =&gt; $post-&gt;post_title
              ];
          }
      }
  
      return wp_send_json($arr_data);
      die();
  }
  add_action('wp_ajax_apcef_city_by_state', 'ag_apcef_city_by_state');
  add_action('wp_ajax_nopriv_apcef_city_by_state', 'ag_apcef_city_by_state');
  </code></pre>