前提・実現したいこと
Custom Post Type UIプラグインとCustom Post Type Permalinksプラグインを使用し、
カスタム投稿タイプを作成しました。
カスタム投稿タイプにタクソノミーを複数設定し、
それぞれのタクソノミーアーカイブページで、タクソノミースラッグをURLから削除したいです。
例)
カスタム投稿「物件検索」
投稿タイプスラッグ = 「bukken」
タクソノミースラッグ① = 「todofuken」
ターム = 「北海道、青森、、、、」
タクソノミースラッグ② = 「eki」
ターム = 「山手線、京浜東北線、、、」
「todofuken」と「eki」をURLから削除したいです。
希望のURL
ドメイン/bukken/東京都/
ドメイン/bukken/山手線/
現状のURL
ドメイン/bukken/todofuken/東京都/
ドメイン/bukken/eki/山手線/
記事詳細ページではタクソノミースラッグは削除されていますが、
タクソノミーアーカイブページでスラッグが削除されません。
発生している問題・エラーメッセージ
下記のソースをfunctions.phpに追記すると「todofuken」のスラッグは削除されましたが、
2つめ以降のタクソノミースラッグ削除ができずに困っています。
該当のソースコード
function my_custom_post_type_permalinks_set($termlink, $term, $taxonomy){ return str_replace('/'.$taxonomy.'/', '/', $termlink); } add_filter('term_link', 'my_custom_post_type_permalinks_set',11,3); function my_custom_post_type_permalinks_rule(){ add_rewrite_rule('bukken/([^/]+)/([^/]+)/page/([0-9]+)/?$', 'index.php?todofuken=$matches[1]/$matches[2]&paged=$matches[3]', 'top'); add_rewrite_rule('bukken/([^/]+)/page/([0-9]+)/?$', 'index.php?todofuken=$matches[1]&paged=$matches[2]', 'top'); add_rewrite_rule('bukken/([^/]+)/([^/]+)/([0-9]+)/?$', 'index.php?post_type=bukken&p=$matches[3]', 'top'); add_rewrite_rule('bukken/([^/]+)/([0-9]+)/?$', 'index.php?post_type=bukken&p=$matches[2]', 'top'); add_rewrite_rule('bukken/([^/]+)/([^/]+)/?$', 'index.php?todofuken=$matches[1]/$matches[2]', 'top'); add_rewrite_rule('bukken/([^/]+)/?$', 'index.php?todofuken=$matches[1]', 'top'); } add_action('init', 'my_custom_post_type_permalinks_rule');
試したこと
下記のプラグインを試しましたが解決しませんでした。
Remove Taxonomy Base Slug
Remove Taxonomy URL
補足情報(FW/ツールのバージョンなど)
WordPress 5.6
あなたの回答
tips
プレビュー