boxmoe_header_banner_img

Hello! 欢迎来到盒子萌!

加载中

文章导读

wordpress主题新建页面链接改为.html方法


avatar
专收爆米花 2018年12月7日 5.42k

很多人喜欢把wordpress博客伪静态展现,文章伪静态规则设定好后台设置的固定链接设置好就好了…^0^~ 唯独新建的页面上没有带.html
如今找到了一个方法让页面链接也是.html结尾后缀

首先在主题的功能文件里functions.php添加以下代码,然后后台设置里的固定链接更新下就好了

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';
    }
}


评论(3)

查看评论列表
评论头像
心跳wvv 2018年12月09日

后台固定连接哪里,页面链接后面跟个.html 不就好了么?

评论头像
专收爆米花 博主 2018年12月09日

@心跳wvv 如果是文章的话后台固定链接改下就好,如果是要新建一个页面的就必须这个代码辅助

比如会员中心默认的页面是/user 更新后是 /user.html

评论头像
敏敏 2018年12月17日

我是不喜欢让rewrite加.html后缀,看起来像十年前的感觉


发表评论

表情 颜文字
插入代码