I’ve configure permastructure for posts to /blog/%postname%/
, I’ve created a page with slug about-us
and I used the code bellow to register team_member
CPT and it is working. I think you had a extra “https://wordpress.stackexchange.com/” in the rewrite argument. Also, you don’t need to works with global $wp_rewrite
; if you set the rewrite argument when the post type is registered, WordPress will create the rewrite rules for you. I’ve also made some comments to save non-needed code:
add_action("init", "register_cpt_team_member");
function register_cpt_team_member() {
$labels = array(
//If "label" is set, the "name" in "labels" argument is usually not needed
//'name' => _x( 'Team Members', 'Post Type General Name', 'client' ),
// [...]
);
$args = array(
//label should a plural descriptive name
'label' => __( 'Team Members', 'client' ),
//description should include ...... a description ;)
'description' => __( 'Custom post type to manage team members', 'client' ),
//As the only "labels" set was "name" and it overriden by general "label" you don't need this
//'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail' ),
//hierarchical is by default false, you don't need this
//'hierarchical' => false,
'public' => true,
//show_ui is by default set to same value of "public", so you don't need this
//'show_ui' => true,
//show_in_menu by default set to same value of "show_ui", so you don't need this
//'show_in_menu' => true,
//show_in_nav_menus is by default set to same value of "public", so you don't need this
//'show_in_nav_menus' => true,
//show_in_admin_bar by default set to same value of "show_in_menu", so you don't need this
//'show_in_admin_bar' => true,
'menu_position' => 5,
//can_export is by default set to true, so you don't need this
//'can_export' => true,
'has_archive' => true,
//exclude_from_search is by default set to opposite of "public", so you don't need this
//'exclude_from_search' => false,
//publicly_queryable is by default set to same value of "public" argumente, so you don't need this
//'publicly_queryable' => true,
'capability_type' => 'page',
'rewrite' => array (
'slug' => '/about-us/team',
'with_front' => false
)
);
register_post_type( 'team_member', $args );
}
So, the above code can be written like this with the same result:
add_action("init", "register_cpt_team_member");
function register_cpt_team_member() {
$args = array(
'label' => __( 'Team Members', 'client' ),
'description' => __( 'Custom post type to manage team members', 'client' ),
'supports' => array( 'title', 'editor', 'thumbnail' ),
'public' => true,
'menu_position' => 5,
'has_archive' => true,
'capability_type' => 'page',
'rewrite' => array (
'slug' => '/about-us/team',
'with_front' => false
)
);
register_post_type( 'team_member', $args );
}