Categories
CMS Mastering Development Wordpress

Invalid Menu Items

I registered a taxonomy named districts, but when I add districts to nav menus, the nav menu items are invalid! Here is the code that registers the taxonomy:


    function masallah() {

    // Add new taxonomy, make it hierarchical like categories
    //first do the translations part for GUI

        $labels = array(
            'name' => _x( 'Districts', 'taxonomy general name' ),
            'singular_name' => _x( 'District', 'taxonomy singular name' ),
            'search_items' =>  __( 'Search Districts' ),
            'all_items' => __( 'All Districts' ),
            'parent_item' => __( 'Parent Districts' ),
            'parent_item_colon' => __( 'Parent District:' ),
            'edit_item' => __( 'Edit District' ),
            'update_item' => __( 'Update District' ),
            'add_new_item' => __( 'Add New District' ),
            'new_item_name' => __( 'New Topic District' ),
            'menu_name' => __( 'Districts' ),
        );

    // Now register the taxonomy

        register_taxonomy('Districts',array('post'), array(
            'hierarchical' => true,
            'labels' => $labels,
            'show_ui' => true,
            'show_admin_column' => true,
            'query_var' => true,
            'show_in_rest' => true,
            'rewrite' => true,
            'rewrite' => array( 'slug' => 'districts' ),
            'has_archive' => true,
        ));

    }

    add_action( 'init', 'masallah', 0 );

Leave a Reply

Your email address will not be published. Required fields are marked *