Support

Account

Home Forums General Issues Custom taxonomies are not fetched with acf Reply To: Custom taxonomies are not fetched with acf

  • When is add_local_field_group called, before or after “init” when the taxonomy is added. I suspect that you are attempting to get the terms in the taxonomy before the taxonomy has been initialized.

    
    function get_terms_for_acf_select() {
        $terms = get_terms(array('taxonomy' => 'teams', 'hide_empty' => false));
        if (is_wp_error($terms)) {
          die ('WP Error Getting Terms');
        }
        $options = array();
    
        if (is_array($terms)) {
            foreach ($terms as $term) {
                if (is_object($term)) {
                    $options[$term->term_id] = $term->term_id;
                }
            }
        }
    
        return $options;
    }