Custom post type clean url

Generate WP can help you generate a clean CPT. If this doesn’t work, try the site to make sure you didn’t miss anything.


// Register Custom Post Type
function custom_post_type() {

    $labels = array(
        'name'                  => _x( 'Teams', 'Post Type General Name', 'text_domain' ),
        'singular_name'         => _x( 'Team', 'Post Type Singular Name', 'text_domain' ),
        'menu_name'             => __( 'Team', 'text_domain' ),
        'name_admin_bar'        => __( 'Team', 'text_domain' ),
        'parent_item_colon'     => __( 'Parent Team:', 'text_domain' ),
        'all_items'             => __( 'All Teams', 'text_domain' ),
        'add_new_item'          => __( 'Add New Team', 'text_domain' ),
        'add_new'               => __( 'Add New', 'text_domain' ),
        'new_item'              => __( 'New Team', 'text_domain' ),
        'edit_item'             => __( 'Edit Team', 'text_domain' ),
        'update_item'           => __( 'Update Team', 'text_domain' ),
        'view_item'             => __( 'View Team', 'text_domain' ),
        'search_items'          => __( 'Search Team', 'text_domain' ),
        'not_found'             => __( 'Not found', 'text_domain' ),
        'not_found_in_trash'    => __( 'Not found in Trash', 'text_domain' ),
        'items_list'            => __( 'Teams list', 'text_domain' ),
        'items_list_navigation' => __( 'Teams list navigation', 'text_domain' ),
        'filter_items_list'     => __( 'Filter teams list', 'text_domain' ),
    );
    $args = array(
        'label'                 => __( 'Team', 'text_domain' ),
        'labels'                => $labels,
        'supports'              => array( 'title', 'editor', 'thumbnail', ),
        'taxonomies'            => array( 'category', 'post_tag' ),
        'hierarchical'          => true,
        'public'                => true,
        'show_ui'               => true,
        'show_in_menu'          => true,
        'menu_position'         => 5,
        'menu_icon'             => get_stylesheet_directory_uri(). '/teamProfiles/team-icon.png',
        'show_in_admin_bar'     => true,
        'show_in_nav_menus'     => true,
        'can_export'            => true,
        'has_archive'           => false,       
        'exclude_from_search'   => false,
        'publicly_queryable'    => true,
        'capability_type'       => 'page',
    );
    register_post_type( 'team', $args );

}
add_action( 'init', 'custom_post_type', 0