前提・実現したいこと
元々ムーバブルタイプでサイトを作成しており、そのサイトをWPに移行しました。
その際、ファイル名(パーマリンク)がムーバブルタイプ時代と若干変わってしまいました。
実装したいのは
「カテゴリの後ろにはスラッシュをつける」
「固定ページの後ろにはスラッシュを付けない」
です。
■以前
http://example.com
http://example.com/category/
http://example.com/category/post_aaa.html(投稿ページ)
http://example.com/category/post_bbb.html(固定ページ)
■現在
http://example.com
http://example.com/category/
http://example.com/category/post_aaa.html(投稿ページ)
http://example.com/category/post_bbb.html/(固定ページ)
■したいこと
http://example.com
http://example.com/category/
http://example.com/category/post_aaa.html(投稿ページ)
http://example.com/category/post_bbb.html(固定ページ)
試したこと
ネットで調べてみて、とりあえず以下のタグをファンクションに入れたら、カテゴリと固定ページの両方にスラッシュが入ってしまいました。
function add_slash_uri_end($uri, $type) {
if ($type != 'single') {
$uri = trailingslashit($uri);
}
return $uri;
}
add_filter('user_trailingslashit', 'add_slash_uri_end', 10, 2);
つまり以下のような状態です。
■現在
http://example.com
http://example.com/category/
http://example.com/category/post_aaa.html(投稿ページ)
http://example.com/category/post_bbb.html/(固定ページ)
補足情報(FW/ツールのバージョンなど)
WordPress 4.9.8
回答2件
あなたの回答
tips
プレビュー