WordPress标签HTML化,代码如下,添加到functions执行代码:
// html链接化
function html_url_rules() {
global $wp_rewrite;
$wp_rewrite->page_structure = $wp_rewrite->root . 'page/%pagename%.html';
$wp_rewrite->extra_permastructs['post_tag']['struct'] = $wp_rewrite->root . 'tag/%post_tag%.html';
}
add_action( 'init', 'html_url_rules' );
// 页面链接添加html后缀
add_action('init', 'html_page_permalink', -1);
function html_page_permalink() {
global $wp_rewrite;
if ( !strpos($wp_rewrite->get_page_permastruct(), '.html')){
$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.html';
}
}