Support

Account

Home Forums Backend Issues (wp-admin) Taxonomy field fails loading categories in backend

Solving

Taxonomy field fails loading categories in backend

  • I’ve created an ACF taxonomy field that should show my categories inside my custom taxonomy. This taxonomy contains categories and has connected posts. Normally the field should show all the categories, but now it wont. Instead it first loads and after that it gives the error ‘Laden mislukt’ which is dutch for something like ‘Loading Failed’. Does someone know what could be the reason the field won’t load anymore? Beside a font issue we dont have specific errors in the console or php-errors when activating the debug.

    Code for registering the custom post type and taxonomy

    
    
            function cpt_kennisartikel() {
                $labels = array(
                    'name'               => _x( 'Kennisartikelen', 'i2sa'),
                    'singular_name'      => _x( 'Kennisartikel', 'i2sa'),
                    'menu_name'          => _x( 'Kennisartikelen', 'i2sa'),
                    'name_admin_bar'     => _x( 'Kennisartikelen', 'i2sa'),
                    'add_new'            => _x( 'New item', 'i2sa'),
                    'add_new_item'       => __( 'Add new item', 'i2sa'),
                    'new_item'           => __( 'New item', 'i2sa'),
                    'edit_item'          => __( 'Edit item', 'i2sa'),
                    'view_item'          => __( 'View item', 'i2sa'),
                    'all_items'          => __( "All items", 'i2sa'),
                    'search_items'       => __( 'Search item', 'i2sa'),
                    'parent_item_colon'  => __( 'Parent item:', 'i2sa'),
                    'not_found'          => __( 'Search query not found.', 'i2sa'),
                    'not_found_in_trash' => __( 'Search query not found.', 'i2sa')
                );
            
                $args = array(
                    'labels'             => $labels,
                    'description'        => "Beschrijving i2sa",
                    'public'             => true, //openbaar
                    'exclude_from_search'=> false, //uitschakelen voor zoekopdrachten
                    'publicly_queryable' => true, //publiekelijk vindbaar
                    'show_in_nav_menus'  => false, //toon in navigatie
                    'menu_icon'          => 'dashicons-lightbulb',
                    'show_ui'            => true,
                    'show_in_menu'       => true,
                    'show_in_rest'       => true,
                    'query_var'          => true,
                    'rewrite'            => array( 'slug' => 'kb' ), //custom url
                    'capability_type'    => 'post',
                    'has_archive'        => false, //heeft archivepage
                    'hierarchical'       => false, // true maakt het een pagina
                    'menu_position'      => 5, //null = geen
                    'supports'           => array('editor', 'title', 'thumbnail'), //gesupporte functionaliteiten
                );
                register_post_type( 'kennisartikel', $args );
        
                //flush_rewrite_rules();
            }
            add_action( 'init', 'cpt_kennisartikel' );
        
        
            function cstm_taxonomy_kb() {
                $post_types = array('kennisartikel');
            
                $taxonomy_args = array(
                    'label' => 'Artikel Categorie (KB)',
                    'rewrite' => array('slug' => 'tax-kb'),
                    'hierarchical' => true,
                    'public' => true,
                    'show_ui' => true,
                    'show_in_rest'       => true,
                    'show_admin_column' => true,
                    'has_archive' => false,
                );
            
                foreach ($post_types as $post_type) {
                    register_taxonomy('cc_tax_kb', $post_type, $taxonomy_args);
                }
            }
            
            add_action('init', 'cstm_taxonomy_kb');
    
    

    Setup of the field and error attached as screenshot.

  • You need to activate error logging and look in your php error log to find a php error. The field is populated with AJAX and you will not see error created during an AJAX request when display errors in on.

    But more than likely there is a PHP error of JavaScript error causing the issue.

  • This reply has been marked as private.
  • This reply has been marked as private.
  • Another issue that could be causing this is that something is outputting something, and this could even be just white space, before ACF sends a response to the AJX request. Issues of this kind are extremely difficult to track down. It can be a plugin conflict or something in the theme, any filter or action that might run during the ajax request could cause it.

    Another issue that could cause this is an extremely large number of terms in the taxonomy.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.