问题:有办法把页面的连接也以html结尾吗?
固定连接已经设为:%postname%.html,当修改页面的固定连接为about.html时候,就自动变成about-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';
- }
- $wp_rewrite->flush_rules();
- }
- add_filter('user_trailingslashit', 'no_page_slash',66,2);
- function no_page_slash($string, $type){
- global $wp_rewrite;
- if ($wp_rewrite->using_permalinks() && $wp_rewrite->use_trailing_slashes==true && $type == 'page'){
- return untrailingslashit($string);
- }else{
- return $string;
- }
- }
复制代码 |