Support

Account

Home Forums Backend Issues (wp-admin) ACF load_field preventing custom taxonomy checkboxes from staying checked Reply To: ACF load_field preventing custom taxonomy checkboxes from staying checked

  • My guess is that the loop in your function is interfering is some way with the global $post value. This can be caused by many things. I actually just had a similar problem on a site myself and it took me a long time to track it down.

    My suggestion, to rule this out, would be to not use have_posts() and the_post() at all and instead to access the post information a different way.

    
    if (count($sectors->posts)) {
      
      foreach ($sectors->posts as $post) {
      
        // vars
        $value = $post->ID;
        $label = ucfirst(str_replace('Fabrication for ', '', $post->post_title));
      
        // append to choices
        $field['choices'][ $value ] = $label;
      
      }
    }
    

    you should not use wp_reset_postdata() if you use the above code