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
Comedy
- post 1
- post 2
- post 3
Action
- 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.
category.php
orarchive.php
or something else entirely. I'm asking because depending on the php file you would need to add someif
checkes (if inarchive.php
)archive.php
, but not 100% sure, as it probably depends on the Avada template.