您可以在register\\u post\\u type中使用rewrite arg。您可以使用不同的自定义post类型名称,然后重写slug。例如,这里是自定义post类型项目的示例代码,它显示了http://shaowtriger.com/brands/naim/
在中重写通知$args
add_action( \'init\', \'codex_brand_init\' );
function codex_brand_init() {
$labels = array(
\'name\' => _x( \'Brands\', \'post type general name\', \'your-plugin-textdomain\' ),
\'singular_name\' => _x( \'Brand\', \'post type singular name\', \'your-plugin-textdomain\' ),
\'menu_name\' => _x( \'Brands\', \'admin menu\', \'your-plugin-textdomain\' ),
\'name_admin_bar\' => _x( \'Brand\', \'add new on admin bar\', \'your-plugin-textdomain\' ),
\'add_new\' => _x( \'Add New\', \'brand\', \'your-plugin-textdomain\' ),
\'add_new_item\' => __( \'Add New Brand\', \'your-plugin-textdomain\' ),
\'new_item\' => __( \'New Brand\', \'your-plugin-textdomain\' ),
\'edit_item\' => __( \'Edit Brand\', \'your-plugin-textdomain\' ),
\'view_item\' => __( \'View Brand\', \'your-plugin-textdomain\' ),
\'all_items\' => __( \'All Brands\', \'your-plugin-textdomain\' ),
\'search_items\' => __( \'Search Brands\', \'your-plugin-textdomain\' ),
\'parent_item_colon\' => __( \'Parent Brands:\', \'your-plugin-textdomain\' ),
\'not_found\' => __( \'No brands found.\', \'your-plugin-textdomain\' ),
\'not_found_in_trash\' => __( \'No brands found in Trash.\', \'your-plugin-textdomain\' )
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'brands\' ),
\'capability_type\' => \'post\',
\'has_archive\' => true,
\'hierarchical\' => false,
\'menu_position\' => null,
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'comments\' )
);
register_post_type( \'project\', $args );
flush_rewrite_rules();
}
虽然有
only 基本页
http://shaowtriger.com/brands/
不应干扰CPT slug和功能,但将子页面设置为页面品牌将不起作用,因为WordPress将查找CPT项目而不是子页面。