尝试以下步骤:
Step #1: 替换此:
add_action( \'init\', \'custom_rewrite_rules\' );
function custom_rewrite_rules() {
add_rewrite_rule(
\'testimonials/([^/]+)(?:/([0-9]+))?/?$\',
\'index.php?category_name=testimonials&name=$matches[1]&page=$matches[2]\',
\'top\' // The rule position; either \'top\' or \'bottom\' (default).
);
}
。。使用此选项:
add_filter( \'category_link\', \'custom_category_permalink\', 10, 2 );
function custom_category_permalink( $link, $cat_id ) {
$slug = get_term_field( \'slug\', $cat_id, \'category\' );
if ( ! is_wp_error( $slug ) && \'testimonials\' === $slug ) {
$link = home_url( user_trailingslashit( \'/testimonials/\', \'category\' ) );
}
return $link;
}
add_action( \'init\', \'custom_rewrite_rules\' );
function custom_rewrite_rules() {
add_rewrite_rule(
\'testimonials(?:/page/?([0-9]{1,})|)/?$\',
\'index.php?category_name=testimonials&paged=$matches[1]\',
\'top\' // The rule position; either \'top\' or \'bottom\' (default).
);
add_rewrite_rule(
\'testimonials/([^/]+)(?:/([0-9]+))?/?$\',
\'index.php?category_name=testimonials&name=$matches[1]&page=$matches[2]\',
\'top\' // The rule position; either \'top\' or \'bottom\' (default).
);
}
Step #2: 转到永久链接设置页面,单击保存更改按钮,而不进行任何更改。