1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 添加类别html页面 WordPress分类/标签/页面的url链接添加html后缀

添加类别html页面 WordPress分类/标签/页面的url链接添加html后缀

时间:2019-11-18 11:48:39

相关推荐

添加类别html页面 WordPress分类/标签/页面的url链接添加html后缀

用WordPress建站的朋友应该能发现,WordPress的页面/分类url链接默认是没有html后缀的,不过有的WordPress主题增加了.html后缀,不过也有的站长不喜欢要后缀,希望自己的网页地址整齐划一,所以使用的是文章id类型的URL。

有没有.html后缀是否对wordpress seo优化有利暂且不说,但是伪静态肯定有利于网站的seo的,所以对于有html后缀的页面,相对而言可能会有效果,大家将信将疑的用着吧。

将下面的代码根据您自己实际需要的功能添加在主题的function.php文件当中即可。

function custom_page_rules() {

global $wp_rewrite;

$wp_rewrite->page_structure = $wp_rewrite->root . ‘page/%pagename%.html’;

$wp_rewrite->extra_permastructs[‘post_tag’][‘with_front’] = ”;

$wp_rewrite->extra_permastructs[‘post_tag’][‘struct’] = $wp_rewrite-

>extra_permastructs[‘post_tag’][‘with_front’] . ‘tag/%post_tag%.html’;

$wp_rewrite->extra_permastructs[‘category’][‘with_front’] = ‘category’;

$wp_rewrite -> extra_permastructs[‘category’][‘struct’] = $wp_rewrite->extra_permastructs[‘category’][‘with_front’].’/%category%.html’;

}

add_action( ‘init’, ‘custom_page_rules’ );

这样就完成了分类/标签/页面的url链接添加html后缀,你是不是已经完成了呢?

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。