#StackBounty: #categories List archived posts by subcategory

Bounty: 100

I would like to override the default post archives, via category.

In some cases (not all), I have 2 level-categories, such as:

Parent Category: "Video"

  • Subcategory "Comedy"
  • Subcategory "Action"

But some other categories, are just single-level.

Currently, no matter which category you choose, you get a list of posts, no matter whether its a main- or sub- category.

What I would like to do, is when entering the category listing, there is a test of sub-categories exist, and if so, the posts should be lists as such:

Heading: Video


  • post 1
  • post 2
  • post 3


  • post 4
  • post 5
  • post 6

If however, there are no subcategories, than the default listing is displayed:

Heading: Books

  • post 7
  • post 8
  • post 9

How can this be done?

I have very basic PHP knowledge, and have a PHPCode script installed, but I’m not sure how to access the archive/category page.

If its relevant, I am using Avada (child) theme.

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.