If I understand correctly you have something like so:
- Category A (Using Template 1)
- Sub-Category 1 (Using Template 2)
- Sub-Category 2 (Using Template 2)
- Category B (Using Template 1)
You might need to add this to your archive-products.php
as a conditional to test if a category has children, and if so show a different layout or design:
<?php
$this_category = get_category($cat);
if (get_category_children($this_category->cat_ID) != "") {
// Category has NO children
}
else{
// Category HAS children
}
?>
Found this answer here: different-template-for-subcategory-any-conditions by triplebull
Hopefully it helps!
Related Posts:
- How to build a complex page structure
- Template tags to display custom post type posts in category template?
- Should I use custom menu, C.P.T. or theme options, or something else for this?
- Archieve.php not loading for custom post type
- Include custom post type custom taxonomies in Categories widget
- Custom post category name showing empty
- Help with Multi Level Category Archive Page
- How To Display Category list from Portfolio post type plugin?
- Having some trouble properly displaying Custom Post Types in templates
- Category names on CPT archive pages [closed]
- Show custom post type on post category page doesn’t work / breaks navigation
- Group posts by custom post type
- What’s the difference between same wp functions get_posts(); functions in different form?
- Display all posts in main category and 1 subcategory
- Replace li Items with divs with classes
- showing custom post types of a certain category only
- One-to-many post relationships that are displayed by category (using posts-to-posts plugin)
- Get posts from a custom post type by child categories of a parent category
- Linking to the most recent post in a Custom Post Type
- Custom Post Type Archive Page Filtering
- Getting posts under the custom post type ui category
- Show category ID on custom post type
- How can I auto-assign a CPT post to category in a custom taxonomy when published?
- What template files do I need to customise custom-category-term-links rather than fall back on archive.php?
- get_posts() with custom post type does not work outside page.php
- Posts from all the categories are being displayed instead of particular category
- Get parent categories of custom post type
- How to query_post custom posts within default taxonomy?
- Conditional Statement custom post type category
- Show custom post type filtered by category
- Custom Post Type With Categories
- Display posts from Custom Post Type in category page on front-end
- Get term name and term parent into custom post type permalink
- Categories sorting
- How can I make my custom posts appear in their assigned category url?
- How to call in Custom Post-Type Categories?
- Allow user to set custom order to a list of custom taxonomies?
- get_category_parents for custom post type taxonomy
- Separate custom categories from default category
- forming WP_Query for posts of all post types but from specific categories
- wp_list_categories() – current-cat class also inside posts?
- Showing posts from different categories and from custom post type
- Custom post type getting wrong categories and tags
- Allow non-logged in users to see a future post after clicking on a list of future posts
- Help need making decision. Ads rotating site on wordpress
- Categories of custom taxonomy don’t show any posts
- How to display custom taxonomies with links in filter menu?
- Query & Order posts by custom fields
- Show a Category X’s custom post type on Category X archive page?
- custom taxonamy and post type
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- PHP variable not regenerating when publishing multiple posts at the same time
- Multiple level category drop-down from the WordPress dashboard
- Return the latest post from a custom Taxonomy and Post Type
- Cannot add category or custom taxonomy from admin. WordPress site is hosted in Windows 16 server via IIS. No XAMPP or WAMP
- Don’t know how to show custom taxonomies from a custom post_type
- Add custom post type settings to wordress default posts
- Hide parent categories when clicked, and show it’s childs
- Limit amount of posts made within a custom taxonomy
- Problem with displaying posts in the CPT category
- Not Able to Get Custom Post Type Gallery Images URL
- Filter CPT posts by one or more categories
- Getting categories of posts under a custom taxonomy
- JS innerhtml changing style when using AJAX
- Custom Post Types with a common category for a blog listing
- Can’t remove front from permalinks for custom taxonomy category page
- How to get categories linked in posts for a specific post type
- Display a grid of taxonomy terms at root taxonomy page
- Custom post type, organized by categories
- How to display “Category and Post_tag” component in a CPT Gutenberg edit screen?
- How to Upload CSV Data into Custom Post Type Data with Metabox programmatically
- How to change the post type a theme shows by default?
- Get unique superset of taxonomy terms from a list of custom posts in another hierarchical taxonomy
- Remove CPT name from permalink but add %category% instead
- Set a checkmark in a category based on a URL-parameter
- WP Query with categories only shows one post and ignores the category
- Adding custom post type to count in category
- How to edit this code to get the categories in achieve page?
- Category with post type pagination returns 404
- Custom Post Type and Category Base Rewrite Issue
- Get the category from custom post type
- Post injections into Site Origins Page builder [closed]
- Custom Post Type + Categories
- How to create a gallery page with categories?
- Event Custom Post Type Title show by upcoming Event Dates
- Custom Post Slug same as Parents Category Slug
- WordPress posts page for customer filtering and sorting along with category filter
- How to have this permalink structure: post_type/postname/custom_inner_page
- I am having Trouble to get list of Categories of Custom post Type
- Hierarchy and access control for Custom Post Types (CPT)
- Multiple (two) category postings on the same page.
- Loop filtering Custom Post Types and/or Categories
- School & class blogs: Categorize with categories or custom posts?
- Building a Treatments Page, What Do I Use?
- Custom post type and category link together
- Why is my category template ignoring post type?
- Best method to make posts searchable, sortable and filterable – custom field, tag or category?
- How to get custom posts sub category link
- Not sure if I should create multiple custom post type [closed]
- Cross reference custom post types