默认WordPress文章页面后缀链接没有html,如https://blog.seo178.com/googleseo ,它再没改动之前文章页面链接https://blog.seo178.com/googleseo
只需要在当前模板目录下functions.php文件中添加代码即刻添加后缀,下面是具体代码片段
WordPress给添加文章后缀html代码
/%postname%.html
/%post_id%.html
1.需要到固定链接设置页面,重新保存一下固定链接设置,否则不会生效。下面是代码
2.页面链接添加html后缀
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';
}
}
给WordPress分类目录和tag分类目录添加斜杠/
下面是排除页面文件代码,否则页面链接.html后面也会自动加上斜杠。
function nice_trailingslashit($string, $type_of_url){
if( $type_of_url !='single'&& $type_of_url !='page')
$string = trailingslashit($string);
return $string;
}
add_filter('user_trailingslashit','nice_trailingslashit',10,2);
等您坐沙发呢!
发表评论
热门文章
分类
最新文章
最近回复
相关文章