您可以尝试slug
agument下rewrite
的参数register_post_type()
功能:
add_action( \'init\', \'egister_hosts_post_type\' );
function register_hosts_post_type() {
$args = array(
// ....
\'rewrite\' => array( \'slug\' => \'programs/hosts\' ),
);
register_post_type( \'hosts\', $args );
}
由于这会影响重写规则,您应该在激活/停用插件时刷新它们:
add_action( \'init\', \'cyb_register_hosts_post_type\' );
function cyb_register_hosts_post_type() {
$args = array(
// ....
\'rewrite\' => array( \'slug\' => \'programs/hosts\' ),
);
register_post_type( \'hosts\', $args );
}
register_activation_hook( __FILE__, \'cyb_activation_hook\' );
function cyb_activation_hook() {
cyb_register_hosts_post_type();
flush_rewrite_rules();
}
register_deactivation_hook( __FILE__, \'cyb_deactivation_hook\' );
function cyb_deactivation_hook() {
flush_rewrite_rules();
}