theme development - Wordpress sub taxonomy template

Please see my code structure Custom post type name : productCustom taxonomy associated with product : categoryMain categ

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.

Share Improve this question edited Apr 24, 2019 at 3:46 butlerblog 5,1313 gold badges28 silver badges44 bronze badges asked Jun 16, 2015 at 8:50 ron rron r 3331 gold badge5 silver badges13 bronze badges 1
  • Your custom taxonomy cannot be called category. This name is already used by the build in taxonomy category – Pieter Goosen Commented Jun 16, 2015 at 8:52
Add a comment  | 

1 Answer 1

Reset to default 1

You 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745561186a4633115.html

相关推荐

  • theme development - Wordpress sub taxonomy template

    Please see my code structure Custom post type name : productCustom taxonomy associated with product : categoryMain categ

    7小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信