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
- How to change permalink structure for custom post type and it’s taxonomies?
- Change permalinks for posts but not for custom post types
- Filtering a custom post type by custom taxonomy in archive template
- Assign single template to multiple custom post types?
- Load custom posts with same tag as page
- Hide/Show only specific categories in wp-admin new-post.php
- How can I fix those issues generated by the Themecheck plugin
- Why is get_post_format() for “Standard” returns empty
- Get categories for a specific post – Custom post type
- Password-protect a custom rss feed
- Rename a current used post type
- Include custom post types in categories widget
- How to get dynamically custom post type that are under a certain category
- Listing and accessing categories for a custom post type
- How to show related posts by category or custom post type?
- Custom Post Type, Two categories, Two columns with Pagination
- New WP_query in template not working with CPT+category on some pages
- Taxonomy list. Order by a specific custom post type count
- Custom/separate categories for custom post type
- Categories not working as expected with custom post type
- adding .current* tags to custom post types and taxonomies
- Display types of posts in edit.php instead of All, Published, Scheduled and Draft
- Page as a child of a Custom Post Type
- Get categories and descriptions from custom post type
- Custom Taxonomy – Tags Metabox is showing instead of Categories
- How to create new category for custom post type?
- How to show CPTs in term archive
- Group posts by custom post type
- How can I auto-assign a CPT post to category in a custom taxonomy when published?
- Help need making decision. Ads rotating site on wordpress
- Categories of custom taxonomy don’t show any posts
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- Not Able to Get Custom Post Type Gallery Images URL
- Can’t remove front from permalinks for custom taxonomy category page
- Display a grid of taxonomy terms at root taxonomy page
- Adding custom post type to count in category
- Building a Treatments Page, What Do I Use?
- Pre-selecting the category for a custom post type
- Custom Post Type Category Link
- Create new custom post and post category of same name
- multiple custom post type on category page
- Two column layout with alphabetical ordering
- Custom Post Type Category URL
- Custom Post Type Categories URL not displaying posts
- WP Query results showing posts outside of category ID
- How to get the current category with custom posts
- Better approach for a WordPress Inventory
- Showing all posts and custom post types by using one category
- Custom meta box in custom post type not working
- List child categories from parent category on custom taxonomy page
- How to properly use Categories with Custom Post Types
- Custom post type category permalinks and archive pages
- How can I tell if I’m on a custom post type archive page?
- Can’t Get Parent and Child Categories of Custom Taxonomy to Display
- How to Enable Ascending or Descending In WordPress Default Built-in Loop
- Display custom post types by category
- How to display posts from a certain category in a bootstrap 5 carousel loop with multiple items?
- How to get the custom post data using post id in WordPress?
- Loop all post on single.php
- Searching in multiple category + URL hierarchy in real estate WordPress site
- Custom post type 404 category page
- How to display custom taxonomy term specific post?
- Category permalinks don’t work even after flushing
- programmatically generated custom post type is created more than once
- How to sort post category using its Description
- Custom WordPress theme not displaying posts from category
- Wanting to list all Post types under a common category
- How to show posts of the same category on a page?
- Modify the category post counting function
- Reuse the “category” slug for a custom post type
- Custom Template for CPT Categories
- call a function when insert and update a custom post type
- Custom post types not displaying per category
- Do not output category and tag URLs
- Dropdown switching subcategories portfolio
- Search form to find custom meta box generated data
- Custom Post type archives / categories give 404
- Custom Post Type – Admin Columns
- Problem to show custom post type in archive page category wise
- Why is my custom form saving with ‘autodraft’ as title and slug?
- Category / Custom Post Type permalink issue
- Categories in custom post types
- Sorting custom post types by category?
- Categories and page filtering with pre_get_posts
- Get all custom_post_type posts + blog posts from one category in a single query
- Select Category as Page Parent
- How to create custom page templates with default page layout framework?
- REQUIRED: The theme uses the register_post_type() function, which is plugin-territory
- Is it possible for post and custom post type to share a category base slug?