您的漂亮URL不起作用,因为您尚未引入该行\'rewrite\' => false,
在args
声明自定义帖子类型时使用数组。
使用此代码解决您的问题。。。。希望这对你有用
//This function is to register the archive page of post type
function add_rewrite_rules($aRules) {
$aNewRules = array(\'nos-soins-et-services/?$\' => \'index.php?post_type=cpt_soins\');
$aRules = $aNewRules + $aRules;
return $aRules;
}
add_filter(\'rewrite_rules_array\', \'add_rewrite_rules\');
//This function is to set your Custom URL Structure and replace it with default structure
function rewrite_flush(){
global $wp_rewrite;
$cpt_soins_structure = \'nos-soins-et-services/%cpt_soins%\';
$wp_rewrite->add_rewrite_tag("%cpt_soins%", \'([^/]+)\', "cpt_soins=");
$wp_rewrite->add_permastruct(\'cpt_soins\', $cpt_soins_structure, false);
$wp_rewrite->flush_rules();
}
add_action(\'init\',\'rewrite_flush\'