admin管理员组文章数量:1023018
Please see my code structure
Custom post type name : product
Custom taxonomy associated with product : category
Main category inside category taxonomy :main1, main2 etc
Sub taxonomy inside main1 : sub1, sub2 etc
I need to create template for all sub category and this templates are same. so I need to create one template only that is suitable for all category taxonomy.
Also I need to know how to get the current taxonomy or sub taxonomy slug inside this template file, and also how to know the current page is main taxonomy page or sub taxonomy page. please explain if you know the answer.
I to create taxonomy-category.php
, but that is not working
Why are taxonomy-category.php
and taxonomy-category-main1.php
not working?
After creating these pages and view products by category it's display Nothing Found.
Please see my code structure
Custom post type name : product
Custom taxonomy associated with product : category
Main category inside category taxonomy :main1, main2 etc
Sub taxonomy inside main1 : sub1, sub2 etc
I need to create template for all sub category and this templates are same. so I need to create one template only that is suitable for all category taxonomy.
Also I need to know how to get the current taxonomy or sub taxonomy slug inside this template file, and also how to know the current page is main taxonomy page or sub taxonomy page. please explain if you know the answer.
I to create taxonomy-category.php
, but that is not working
Why are taxonomy-category.php
and taxonomy-category-main1.php
not working?
After creating these pages and view products by category it's display Nothing Found.
1 Answer
Reset to default 1You cannot use category slug as its the default slug for WordPress category. Try register your taxonomy with some other taxonomy name like product-category and use taxonomy-product-category.php file to render individual taxonomy category layout(main1, main2 etc.)
Function Reference/register taxonomy.
Please see my code structure
Custom post type name : product
Custom taxonomy associated with product : category
Main category inside category taxonomy :main1, main2 etc
Sub taxonomy inside main1 : sub1, sub2 etc
I need to create template for all sub category and this templates are same. so I need to create one template only that is suitable for all category taxonomy.
Also I need to know how to get the current taxonomy or sub taxonomy slug inside this template file, and also how to know the current page is main taxonomy page or sub taxonomy page. please explain if you know the answer.
I to create taxonomy-category.php
, but that is not working
Why are taxonomy-category.php
and taxonomy-category-main1.php
not working?
After creating these pages and view products by category it's display Nothing Found.
Please see my code structure
Custom post type name : product
Custom taxonomy associated with product : category
Main category inside category taxonomy :main1, main2 etc
Sub taxonomy inside main1 : sub1, sub2 etc
I need to create template for all sub category and this templates are same. so I need to create one template only that is suitable for all category taxonomy.
Also I need to know how to get the current taxonomy or sub taxonomy slug inside this template file, and also how to know the current page is main taxonomy page or sub taxonomy page. please explain if you know the answer.
I to create taxonomy-category.php
, but that is not working
Why are taxonomy-category.php
and taxonomy-category-main1.php
not working?
After creating these pages and view products by category it's display Nothing Found.
-
Your custom taxonomy cannot be called
category
. This name is already used by the build in taxonomycategory
– Pieter Goosen Commented Jun 16, 2015 at 8:52
1 Answer
Reset to default 1You cannot use category slug as its the default slug for WordPress category. Try register your taxonomy with some other taxonomy name like product-category and use taxonomy-product-category.php file to render individual taxonomy category layout(main1, main2 etc.)
Function Reference/register taxonomy.
本文标签: theme developmentWordpress sub taxonomy template
版权声明:本文标题:theme development - Wordpress sub taxonomy template 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745561185a2156170.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
category
. This name is already used by the build in taxonomycategory
– Pieter Goosen Commented Jun 16, 2015 at 8:52