How to Show Parent Category Products Only Without Subcategories

From this tutorial you’ll learn how to show Parent category products only without products from subcategories.

Excluding Subcategory Products from Parent Category Products List
  • First, let’s log in to WordPress Dashboard. Here you need to open Appearance > Editor tab on the left.
  • Locate functions.php file in the column on the right of the Editor page.
  • Scroll the content of the file to its end, and paste the following lines of code at the end of the code.

https://gist.github.com/Shininglow/9376386f1ad4d5cbed2fbdca9513f23a

  • Click on Update File button to save the changes.
  • As a result, you’ll see only the products assigned to the parent category on the corresponding website’s page.
Online store integration