Remove Sub Categories From Genesis Loop Archives

The 1st code snippet in this tutorial enables you to modify the Genesis loop while maintaining the default markup used to display all archives. You can use this code to remove all posts from all subcategories. Posts in sub categories display on all archive types including any blog listings page, archive, author, blog, category, search, and tag pages by default.

The code removes posts assigned to all sub categories from all archive page types.

You can use any WP Query parameters with the code in this post.

Here’s an example showing posts from sub categories included in the home page loop in the 1st image:

include-sub-categories

And the 2nd image showing all posts from all subcategories removed:

no-sub-categories

Code Usage – Globally or Specific Archives

If you want the code to effect all archive type loops, add it to your child themes functions.php file.

If you only want the code to effect a specific archive, place the code in a archive.php, category.php or other type of archive file using the WordPress Template Hierarchy to name the file.

Also included in this post is a 2nd code snippet which removes all posts from all sub categories from displaying on all parent category archive pages.

Here’s the code for members:

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.