因为您不需要CPT archvie,最简单的使用方法example.com/new-site
打开页面,然后example.com/new-site/post-slug
要打开“新站点”帖子类型的单个帖子,需要声明has_archive => false
注册CPT时:
add_action( \'init\', \'cyb_register_cpt\' );
function cyb_register_cpt() {
$args = array(
// .....
\'has_archive\' => false
);
register_post_type( \'new-site\', $args );
}
PD:记住刷新重写规则:
add_action( \'init\', \'cyb_register_cpt\' );
function cyb_register_cpt() {
$args = array(
// .....
\'has_archive\' => false
);
register_post_type( \'new-site\', $args );
}
register_activation_hook( __FILE__, function () {
cyb_register_cpt();
flush_rewrite_rules();
} );
register_deactivation_hook( __FILE__, function () {
flush_rewrite_rules();
} );