为WordPress页面添加html结尾

之前一直没留意固定连接,今天得空整理下,发现除了分类是以文件结尾外,文章页面也是以/文件来结尾。所以都手修改了下。。。

html结尾

代码如下,直接添加在模版函数即可functions.php。

/*
*WordPress页面链接添加html后缀
*地址:https://sheruo.com/327.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);

记得添加完到后台设置,固定连接设置保存一下即可。

为WordPress页面添加html结尾》有2个想法

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注