尝试将以下内容添加到functions.php:
function wpse221475_custom_rewrite_rules() {
  add_rewrite_rule(
    \'^(special-project)?\', 
    \'index.php?post_type=projects&name=$matches[1]\', 
    \'top\'
  );
}
add_action(\'init\', \'wpse221475_custom_rewrite_rules\');
 请确保在添加此规则后刷新重写规则。
访问:
Dashboard -> Settings -> Permalinks
或者,如果您愿意,您可以使用
flush_rewrite_rules() 以编程方式。
重定向请求http://example.com/projects/special-project 到http://example.com/special-project 您可以在wp 钩
function wpse221475_redirect_request($wp) {
    if ( ! empty($wp->request) && $wp->request === \'projects/special-project\' ) {
        wp_redirect(home_url(\'special-project\'), 301);
        exit;
    }
}
add_action(\'wp\', \'wpse221475_redirect_request\');
 当然,您可以使用其他方式/方法来实现相同的效果,但以上内容就足够了。