Reputation: 53
I want to include a list of subcategories on the category page, and I see some decent answers here on StackOverflow, however my theme doesn't seem to have categories.php file that I'll edit. Any suggestions? Should I create it and then fill it in?
Upvotes: 0
Views: 1389
Reputation: 111
The WordPress template hierarchy is designed so that if one file does not exist, it goes to the next file closer to the trunk of the hierarchy. Take a look at the WordPress template hierarchy:
If your theme does not have a category.php template file, then it is going to default to archive.php when you open up a category page in the browser. Take a look at your archive.php file in your theme and see if there are any conditionals made for category pages. If there are, you can try modifying that conditional block to add in your custom code.
If not, go ahead and make a category.php. You can copy archive.php and then add adjustments to the template to customize it for a category, as opposed to just any generic list of archives (as archive.php is).
If you want to see how to list categories in WP, check out the Codex:
https://codex.wordpress.org/Template_Tags/wp_list_categories
(also, I should add, as you can see from the WP Template hierarchy page, if there is no category.php, and no archive.php, then it checks for the is_page(); conditional, and then loads your base index.php file. Your theme must have an index.php, so if all of those other templates are missing, feel free to copy index.php, rename it category.php, and make your adjustments based on that.).
Upvotes: 1