我认为这是可能的,但您需要关注重写规则的顺序。为了帮助你,我推荐a plugin I wrote to analyze the rewrite rules (很快将在存储库中提供,但您可以download a pre-release).
首先,这些规则非常通用,因此应该放在规则列表的末尾。默认操作是将它们放在顶部,因此我们防止出现默认情况,并自己添加它们。我们已经在底部有了通用页面规则,因此我们应该使它们显式化,并通过启用详细页面规则将它们移到顶部。当你有很多页面时,这是没有效率的,但我认为现在没有其他方法可以做到这一点。
add_action( \'init\', \'wpse6342_init\' );
function wpse6342_init()
{
// Register your taxonomy. `\'rewrite\' => false` is important here
register_taxonomy( \'wpse6342\', \'post\', array(
\'rewrite\' => false,
\'label\' => \'WPSE 6342\',
) );
// Enable verbose page rules, so all pages get explicit and not generic rules
$GLOBALS[\'wp_rewrite\']->use_verbose_page_rules = true;
}
add_action( \'generate_rewrite_rules\', \'wpse6342_generate_rewrite_rules\' );
function wpse6342_generate_rewrite_rules( &$wp_rewrite )
{
// This code is based on the rewrite code in `register_taxonomy()`
// This rewrite tag (%wpse6342%) is just a placeholder to use in the next line
// \'wpse6342=` should be the same as the `query_var` when registering the taxonomy
// which is the name of the taxonomy by default
// `(.+?)` works for a hierarchical taxonomy
$wp_rewrite->add_rewrite_tag( \'%wpse6342%\', \'(.+?)\', \'wpse6342=\' );
// This will generate the actual rewrite rules, and put the at the end of the list
$wp_rewrite->rules += $wp_rewrite->generate_rewrite_rules( $wp_rewrite->front . \'%wpse6342%\', EP_NONE );
}