我目前的permalink结构是/%category%/%postname%/
生成URL为:
(使用“FV Top Level Categories”插件删除category\\u base)
category: example.com/class-10/science/ ◀▬ SLASH is GOOD for directories & ↙ parent pages
page: example.com/legal/
post: example.com/class-10/science/ch-1-atoms/ ◀▬ but BAD for single_post, ↖ child pages &
page: example.com/legal/terms/
page: example.com/about/ ◀▬ standalone pages
所以,我想
keep 尾随斜杠“/"E;日期:
类别和子类别父页remove 尾部斜杠“/"E;日期:
独立页面(没有任何子页面的用户)
子页面AND "301" Redirect "/" version of these ↖ pages to NON "/" version pages
SO网友:Nitin Kumar
经过这么多的研究,我通过https://stackoverflow.com/a/54251892/10403689 (对此进行投票⬆向上⬆)
您的Permalink结构应为:/%category%/%postname%/
function no_post_slash( $string, $type ){
if($type == \'single\')
$string = untrailingslashit($string);
return $string;
}
add_filter(\'user_trailingslashit\', \'no_post_slash\', 70, 2);
但这只适用于single\\u post,不适用于页面