- This topic has 3 replies, 3 voices, and was last updated 6 months, 2 weeks ago by David.
September 6, 2022 at 12:52 am #2334514Anastasia
I have created a custom post type (product) and taxonomy (product_category’). For creating the layouts I need for single post and category archive. I used archive.php and single.php which they were renamed to “taxonomy-product_category.php” and “single-product.php” where I’ve put all my code in order to customize the layout of category archive and single product page.
Since now everything works like a charm.
Although I need for some specific categories of my post type taxonomy to have a complete different layout and content than the default I’ve made which is the “taxonomy-product_category.php” template file. After some reading I tried to seperate lets say the category “A” from all others using the Custom Taxonomy Hierarchy logic
Unfortunately though none of the above methods seems working since as far as I can understand whatever .php file I create in order to seperate the template for category “A” my “taxonomy-product_category.php” overides it.
Do you have any idea why or any kind of work around?September 6, 2022 at 1:55 am #2334572Fernando Customer Support
WordPress follows the Template Hierarchy: https://developer.wordpress.org/files/2014/10/Screenshot-2019-01-23-00.20.04.png
In the image above, WordPress will check if a template exists and moves from left to right.
So, if you have a template with a higher hierarchy, all other templates wont be used. You’ll need to rename your templates accordingly.September 6, 2022 at 1:59 am #2334577Anastasia
You got me a little bit confused now. As far as I can see my case in the table of hierarchy you posted is “Custom Taxonomy Archive” which refers to my “taxonomy-product_category.php” file. So as far as I can understand, if I create a file lets say “category_a.php” for the specific category I need it will overide “taxonomy-product_category.php” which is next in priority?September 6, 2022 at 2:39 am #2334608DavidStaffCustomer Support
for example in your
product_categoryyou add a new term called:
The template name for the shoes category archive would be:
Adding CSS: http://docs.generatepress.com/article/adding-css/
- You must be logged in to reply to this topic.