This custom loop template enables you to display products from a specific parent or child category by I.D in WooCommerce. All you need to do is add the parent category i.d to the template and it will display all products for that taxonomy term level only and NOT products from child categories below the parent level.
The video shows the live test site with 2 links in the menu.
- The 1st link to the default archive for the sub/child category named smaller which displays products from the smaller parent and all child/sub categories which total 5 entries.
- The 2nd menu item links to the custom smaller archive which loads a custom page template with a custom loop removing products from other child categories and only displaying products for the smaller sub category which total 1 entry unlike the default archive which displays products from all sub/child categories including children and below the parent term.
There’s only 1 step :
Upload the template file named custom.php to your child theme folder, templates folder or custom functionality plugin and select it from the Page Attributes box on the Edit Page screen as seen in the demo video.