wordpress固定链接设置伪静态只能文章页面伪静态,而独立页面并不会静态化,今天在雅兮网看到了使用代码即可设置页面的伪静态,发文收藏备用,也希望能给网友有所帮助。
代码放在模板函数文件中
// 页面链接添加html后缀
function html_page_permalink() {
global $wp_rewrite;
if ( !strpos($wp_rewrite->get_page_permastruct(), '.html')){
$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.html';
}
}
add_action('init', 'html_page_permalink', -1);