admin管理员组文章数量:1122826
I've seen similar questions posted before but they don't seem to quite fit my problem.
I have a post type called product and I have 2 taxonomies, product_cat and location
I want archive pages that combine both these taxonomies which would be structured like this /product/product_cat/location
I know this can be done with rewrites but I can't figure out how to make it work.
Update
I've achieved this to an extent using
add_rewrite_rule( '^art-classes/([^/]*)/([^/]*)/?',
'index.php?product_cat=$matches[1]&location=$matches[2]',
'top' );
But now my single product page won't load. it just loads the archive page still. Something wrong with my regex?
I've seen similar questions posted before but they don't seem to quite fit my problem.
I have a post type called product and I have 2 taxonomies, product_cat and location
I want archive pages that combine both these taxonomies which would be structured like this /product/product_cat/location
I know this can be done with rewrites but I can't figure out how to make it work.
Update
I've achieved this to an extent using
add_rewrite_rule( '^art-classes/([^/]*)/([^/]*)/?',
'index.php?product_cat=$matches[1]&location=$matches[2]',
'top' );
But now my single product page won't load. it just loads the archive page still. Something wrong with my regex?
Share Improve this question edited Aug 31, 2016 at 19:05 Luke Seall asked Aug 31, 2016 at 13:16 Luke SeallLuke Seall 3303 silver badges17 bronze badges 01 Answer
Reset to default 0function custom_rewrite_rules() {
add_rewrite_rule( '^art-classes/([^/]*)/([^/]*)/?$',
'index.php?product_cat=$matches[1]&location=$matches[2]',
'top' );
}
add_action('init', 'custom_rewrite_rules');
The $ at the end did the job. Not sure why.
本文标签: taxonomyRewrite permalink to include multiple taxonomies
版权声明:本文标题:taxonomy - Rewrite permalink to include multiple taxonomies 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736294193a1929304.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论