skip to Main Content

I am using WP, coded CPTs and coded custom taxonomies.

I have included the code used for one of the CPTs and one of the Custom Taxonomies below. (CPT code is in functions.php, taxonomy code is in it’s own .php file)

Problem is – these aren’t appearing in the Dashboard menu (as in, when you hover over Private Tours, there is no ‘Destinations’ submenu), and they aren’t appearing on the All Private Tours page as a column option.

I have tried searching for solutions but I believe the code is correct! I just cannot work out why it isn’t showing?


function create_post_type() {
    
    register_post_type( 'Private Tours', // change the name
        array(
            'labels' => array(
                'name' => __( 'Private Tours' ), // change the name
                'singular_name' => __( 'Private Tour' ), // change the name
            ),
            'public' => true,
            'supports' => array ( 'title', 'editor', 'custom-fields', 'page-attributes', 'thumbnail' ), // do you need all of these options?
            'taxonomies' => array( 'category', 'post_tag' ),
            'hierarchical' => true,
            'menu_icon' => get_bloginfo( 'template_directory' ) . "/images/icon.png",
            'has_archive' => true,
            'rewrite' => array ( 'slug' => __( 'private_tours' ) ) // change the name
        )
    );
add_action( 'init', 'create_post_type' );

endif;



function averetourism_register_destination_taxonomy() {
    register_taxonomy( 'destination', array( 'product' ), array(
        'labels'                     => array(
            'name'                       => _x( 'Destinations', 'Taxonomy General Name', 'averetourism' ),
            'singular_name'              => _x( 'Destination', 'Taxonomy Singular Name', 'averetourism' ),
            'menu_name'                  => __( 'Destinations', 'averetourism' ),
            'all_items'                  => __( 'All Destinations', 'averetourism' ),
            'parent_item'                => __( 'Parent Destination', 'averetourism' ),
            'parent_item_colon'          => __( 'Parent Destination:', 'averetourism' ),
            'new_item_name'              => __( 'New Destination Name', 'averetourism' ),
            'add_new_item'               => __( 'Add New Destination', 'averetourism' ),
            'edit_item'                  => __( 'Edit Destination', 'averetourism' ),
            'update_item'                => __( 'Update Destination', 'averetourism' ),
            'view_item'                  => __( 'View Destination', 'averetourism' ),
            'separate_items_with_commas' => __( 'Separate destinations with commas', 'averetourism' ),
            'add_or_remove_items'        => __( 'Add or remove destinations', 'averetourism' ),
            'choose_from_most_used'      => __( 'Choose from the most used', 'averetourism' ),
            'popular_items'              => __( 'Popular Destinations', 'averetourism' ),
            'search_items'               => __( 'Search Destinations', 'averetourism' ),
            'not_found'                  => __( 'Not Found', 'averetourism' ),
            'no_terms'                   => __( 'No destinations', 'averetourism' ),
            'items_list'                 => __( 'Destinations list', 'averetourism' ),
            'items_list_navigation'      => __( 'Destinations list navigation', 'averetourism' ),
        ),
        'hierarchical'               => true,
        'public'                     => true,
        'show_ui'                    => true,
        'show_admin_column'          => true,
        'show_in_nav_menus'          => true,
        'show_tagcloud'              => false,
        'show_in_menu'               => true,
        'menu_position'              => 5,
    ) );
}
add_action( 'init', 'averetourism_register_destination_taxonomy', 0 ); ```

2

Answers


  1. Chosen as BEST ANSWER

    Part solved -

    I had to change some of the arrays to -

    function create_post_type() {
        
        register_post_type( 'Private Tours', // change the name
            array(
                'labels' => array(
                    'name' => __( 'Private Tours' ), // change the name
                    'singular_name' => __( 'Private Tour' ), // change the name
                ),
                'public' => true,
                'supports' => array ( 'title', 'editor', 'custom-fields', 'page-attributes', 'thumbnail' ), // do you need all of these options?
                'taxonomies' => array( 'category', 'post_tag' , 'destination' ),
                'hierarchical' => true,
                'menu_icon' => get_bloginfo( 'template_directory' ) . "/images/icon.png",
                'has_archive' => true,
                'rewrite' => array ( 'slug' => __( 'private_tours' ) ) // change the name
            )
        );
    
    }
    add_action( 'init', 'create_post_type' );
    
    
    
    
    
    function averetourism_register_destination_taxonomy() {
        register_taxonomy( 'destination', array( 'product' , 'private_tours' ), array(
            'labels'                     => array(
                'name'                       => _x( 'Destinations', 'Taxonomy General Name', 'averetourism' ),
                'singular_name'              => _x( 'Destination', 'Taxonomy Singular Name', 'averetourism' ),
                'menu_name'                  => __( 'Destinations', 'averetourism' ),
                'all_items'                  => __( 'All Destinations', 'averetourism' ),
                'parent_item'                => __( 'Parent Destination', 'averetourism' ),
                'parent_item_colon'          => __( 'Parent Destination:', 'averetourism' ),
                'new_item_name'              => __( 'New Destination Name', 'averetourism' ),
                'add_new_item'               => __( 'Add New Destination', 'averetourism' ),
                'edit_item'                  => __( 'Edit Destination', 'averetourism' ),
                'update_item'                => __( 'Update Destination', 'averetourism' ),
                'view_item'                  => __( 'View Destination', 'averetourism' ),
                'separate_items_with_commas' => __( 'Separate destinations with commas', 'averetourism' ),
                'add_or_remove_items'        => __( 'Add or remove destinations', 'averetourism' ),
                'choose_from_most_used'      => __( 'Choose from the most used', 'averetourism' ),
                'popular_items'              => __( 'Popular Destinations', 'averetourism' ),
                'search_items'               => __( 'Search Destinations', 'averetourism' ),
                'not_found'                  => __( 'Not Found', 'averetourism' ),
                'no_terms'                   => __( 'No destinations', 'averetourism' ),
                'items_list'                 => __( 'Destinations list', 'averetourism' ),
                'items_list_navigation'      => __( 'Destinations list navigation', 'averetourism' ),
            ),
            'hierarchical'               => true,
            'public'                     => true,
            'show_ui'                    => true,
            'show_admin_column'          => true,
            'show_in_nav_menus'          => true,
            'show_tagcloud'              => false,
            'show_in_menu'               => true,
            'menu_position'              => 5,
        ) );
    }
    add_action( 'init', 'averetourism_register_destination_taxonomy', 0 ); 
    

    FOLLOW UP QUESTION:

    I got the taxonomies to show up on the dashboard menu, but one of them is still not showing up on Appearance > Menus to allow me to auto add the links to the nav menu... they all have

    'show_in_nav_menus'          => true, 
    'show_in_menu'               => true,
    

    but this one taxonomy isn't showing.. any ideas?


  2. Please replace and try with the below code –

        function create_post_type() {
            
            register_post_type( 'Private Tours', // change the name
                array(
                    'labels' => array(
                        'name' => __( 'Private Tours' ), // change the name
                        'singular_name' => __( 'Private Tour' ), // change the name
                    ),
                    'public' => true,
                    'supports' => array ( 'title', 'editor', 'custom-fields', 'page-attributes', 'thumbnail' ), // do you need all of these options?
                    'taxonomies' => array( 'category', 'post_tag' ),
                    'hierarchical' => true,
                    'menu_icon' => get_bloginfo( 'template_directory' ) . "/images/icon.png",
                    'has_archive' => true,
                    'rewrite' => array ( 'slug' => __( 'private_tours' ) ) // change the name
                )
            );
    
        }
        add_action( 'init', 'create_post_type' );
        
    
        
        
        
        function averetourism_register_destination_taxonomy() {
            register_taxonomy( 'destination', array( 'product' ), array(
                'labels'                     => array(
                    'name'                       => _x( 'Destinations', 'Taxonomy General Name', 'averetourism' ),
                    'singular_name'              => _x( 'Destination', 'Taxonomy Singular Name', 'averetourism' ),
                    'menu_name'                  => __( 'Destinations', 'averetourism' ),
                    'all_items'                  => __( 'All Destinations', 'averetourism' ),
                    'parent_item'                => __( 'Parent Destination', 'averetourism' ),
                    'parent_item_colon'          => __( 'Parent Destination:', 'averetourism' ),
                    'new_item_name'              => __( 'New Destination Name', 'averetourism' ),
                    'add_new_item'               => __( 'Add New Destination', 'averetourism' ),
                    'edit_item'                  => __( 'Edit Destination', 'averetourism' ),
                    'update_item'                => __( 'Update Destination', 'averetourism' ),
                    'view_item'                  => __( 'View Destination', 'averetourism' ),
                    'separate_items_with_commas' => __( 'Separate destinations with commas', 'averetourism' ),
                    'add_or_remove_items'        => __( 'Add or remove destinations', 'averetourism' ),
                    'choose_from_most_used'      => __( 'Choose from the most used', 'averetourism' ),
                    'popular_items'              => __( 'Popular Destinations', 'averetourism' ),
                    'search_items'               => __( 'Search Destinations', 'averetourism' ),
                    'not_found'                  => __( 'Not Found', 'averetourism' ),
                    'no_terms'                   => __( 'No destinations', 'averetourism' ),
                    'items_list'                 => __( 'Destinations list', 'averetourism' ),
                    'items_list_navigation'      => __( 'Destinations list navigation', 'averetourism' ),
                ),
                'hierarchical'               => true,
                'public'                     => true,
                'show_ui'                    => true,
                'show_admin_column'          => true,
                'show_in_nav_menus'          => true,
                'show_tagcloud'              => false,
                'show_in_menu'               => true,
                'menu_position'              => 5,
            ) );
        }
        add_action( 'init', 'averetourism_register_destination_taxonomy', 0 ); 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search