WordPress 栏目分类 添加 html 后缀结尾 代码
找到主题模板文件,模板函数 (functions.php)
添加以下代码
// 设置分类,页面,TAG HTML结尾
function 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', 'custom_page_rules' );