尝试使用wp\\U重写:
add_action(\'init\', \'flush_rewrite_rules\');
function custom_add_rewrite_rules( $wp_rewrite ) {
$new_rules = array(
\'archive/(\\d+)\' => \'/?p=\' . $wp_rewrite->preg_index(1)
);
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
add_action(\'generate_rewrite_rules\', \'custom_add_rewrite_rules\');
使用flush\\u rewrite\\u规则的插件激活挂钩,因为您只希望在开发过程中始终发生这种情况。在生产中,只有在激活插件时才会发生这种情况。
有关flush\\u rewrite\\u规则的详细信息:flush_rewrite_rules @ WordPress.org