I’m trying to accomplish a three-step page hierarchy in WordPress.
Here’s an example of what a breadcrumb navigation might look like:
Mathematics > Algebra > Variables
I’ve got a page that lists all of my top-level categories:
<?php wp_list_categories('depth=1'); ?>
What I need next is to make it so when you click a category, it links you to a page that just lists all of its subcategories. By default it takes you to a page with every post in that category.
So you could select say Math on the first page, followed by a page with sub-categories like Arithmetic, Algebra, Geometry, and then when you select your sub-cat it takes you to the posts.
I’m open to using any alternative methods too if you’ve any ideas on a better way to do it. Using the built-in category system just seemed most appropriate.
wp_list_categories can take an argument, ‘child_of’, that will return a list of child categories. So, in your individual category listing page, you can use the category id of the relevant category to retrieve the children like this:
Further documentation for wp_list_categories can be found here: http://codex.wordpress.org/Template_Tags/wp_list_categories