teratailで似たような質問がありますが
そちらでも回答がありません。
もしかしてかなり難しい案件なのでしょうか?
類似の質問
https://teratail.com/questions/46363
CPT UIとCustom Post Type Permalinksを使用して
以下のようなカスタム投稿タイプを作っています。
投稿タイプ:arrival
タクソノミー:arrivaltype
ターム親:cut
ターム子:pink
実現したいURLの表記は下記です。
http://●●.com/arrival/
http://●●.com/arrival/cut/
http://●●.com/arrival/cut/pink/
http://●●.com/arrival/cut/pink/記事/
パーマリンク設定で
http://●●.com/arrival/%arrivaltype%/%postname%/
としているので記事のURLは実現できました。
下記もカスタム投稿でアーカイブありにしているので実現できました。
http://●●.com/arrival/
http://●●.com/arrival/cut/
ほかの
http://●●.com/arrival/cut/pink/
が、404エラーになります。
function.phpでは
下記のように記載してます。
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); add_rewrite_rule('arrival/([^/]+)/?$', 'index.php?arrivaltype=$matches[1]', 'top'); add_rewrite_rule('arrival/([^/]+)/page/([0-9]+)/?$', 'index.php?arrivaltype=$matches[1]&paged=$matches[2]', 'top');
ご教授いただけると助かります。
あなたの回答
tips
プレビュー