• naulacambra

    (@naulacambra)


    Hi everyone.

    It’s been awhile since I’ve been working with WordPress, but is the first time I try to create taxonomies and post types.

    This is my code

    function portfolio_register() {
    
        $labels = array(
            'name' => _x('Portfolio', 'post type general name'),
            'singular_name' => _x('Portfolio Item', 'post type singular name'),
            'add_new' => _x('Add New', 'portfolio item'),
            'add_new_item' => __('Add New Portfolio Item'),
            'edit_item' => __('Edit Portfolio Item'),
            'new_item' => __('New Portfolio Item'),
            'view_item' => __('View Portfolio Item'),
            'search_items' => __('Search Portfolio'),
            'not_found' => __('Nothing found'),
            'not_found_in_trash' => __('Nothing found in Trash'),
            'parent_item_colon' => ''
        );
    
        $args = array(
            'labels' => $labels,
            'public' => true,
            'publicly_queryable' => true,
            'show_ui' => true,
            'query_var' => true,
            'menu_icon' => get_stylesheet_directory_uri() . '/images/project.png',
            'rewrite' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'supports' => array('title', 'editor', 'thumbnail')
        );
    
        register_post_type('portfolio', $args);
    
        register_taxonomy("types", "portfolio", array(
            "hierarchical" => true,
            "label" => "Types",
            "labels" => array(
                "name" => "Types",
                "singular_label" => "Type"))
        );
    }
    
    add_action('init', 'portfolio_register');

    All works fine, except when I try to add an Type item to the menu. The box that appears in the menu, is red, and has a label saying “Invalid”. What am I doing wrong?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Taxonomy show up as "invalid" when I try to add an item to Menu’ is closed to new replies.