将下面代码添加主题functions.php中:
// 页面链接添加html后缀
add_action(‘init’, ‘html_page_permalink’, -1);
function html_page_permalink() {
global
w
p
r
e
w
r
i
t
e
;
i
f
(
!
s
t
r
p
o
s
(
wp_rewrite; if ( !strpos(
wprewrite;if(!strpos(wp_rewrite->get_page_permastruct(), ‘.html’)){
$wp_rewrite->page_structure = $wp_rewrite->page_structure . ‘.html’;
}
}
添加后,需要到固定链接设置页面,重新保存一下固定链接设置,否则不会生效。(但是这样所有的自建页面都会带上.html后缀!)
上述代码适合伪静态的固定链接形式使用!
常用的伪静态固定链接后加(.html):
/post-%post_id%.html
/%post_id%.html