wp子主题中页面.html增加后缀无效

我把如下代码放在xxx-child子主题文件夹的fuction.php文件中,没效果,但放在父主题有效。
我想放在子主题中有效,免得升级父主题又要加这段代码。请问是哪个地方需要更改?

<?php
// 页面链接添加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';
    }
}
//目录添加斜杠
function nice_trailingslashit($string, $type_of_url) {
    if ( $type_of_url != 'single' && $type_of_url != 'page'&& $type_of_url != 'paged'&& $type_of_url != 'single_paged' )
      $string = trailingslashit($string);
    return $string;
}
add_filter('user_trailingslashit', 'nice_trailingslashit', 10, 2);

?>
阅读 1.4k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题