将下面的代码添加至当前使用的WordPress主题的functions.php中即可。
function xintheme_custom_page_rules() {
global $wp_rewrite;
$wp_rewrite->page_structure = $wp_rewrite->root . 'page/%pagename%.html';
$wp_rewrite->extra_permastructs['post_tag']['with_front'] = '';
$wp_rewrite->extra_permastructs['post_tag']['struct'] = $wp_rewrite->extra_permastructs['post_tag']['with_front'] . 'tag/%post_tag%.html';
$wp_rewrite->extra_permastructs['category']['with_front'] = 'category';
$wp_rewrite->extra_permastructs['category']['struct'] = $wp_rewrite->extra_permastructs['category']['with_front'].'/%category%.html';
}
add_action( 'init', 'xintheme_custom_page_rules' );
global $wp_rewrite;
$wp_rewrite->page_structure = $wp_rewrite->root . 'page/%pagename%.html';
$wp_rewrite->extra_permastructs['post_tag']['with_front'] = '';
$wp_rewrite->extra_permastructs['post_tag']['struct'] = $wp_rewrite->extra_permastructs['post_tag']['with_front'] . 'tag/%post_tag%.html';
$wp_rewrite->extra_permastructs['category']['with_front'] = 'category';
$wp_rewrite->extra_permastructs['category']['struct'] = $wp_rewrite->extra_permastructs['category']['with_front'].'/%category%.html';
}
add_action( 'init', 'xintheme_custom_page_rules' );
添加代码后,到WordPress后台》设置》固定连接,重新保存一下设置。
注意:此功能不可与【去除固定连接中的「category」标志开关】同时使用。