Help with site hierarchy
-
I’m 100% sure this has been answered several times, but I cannot for the live of me find an implementation that works.
I have this structure:
some_fake_site/topics/math/arithmetic/lesson_0.htmlIn the main nav are the various topics.
When I navigate to one, I want to see the various subjects in that topic.
So on /topics/math, I see arithmetic, geometry, algebra, etc.
When I click on one of those topics, I want to arrive at a list of lessons for that topic. /topics/math/geometry should be a list of geometry lessons.That sounds so much easier than…
Ideally, I’d like to accomplish this with categories and the loop,
In the admin panel, I have post categories set up such that there are only posts in child categories. (No single post is tagged algebra, because that’s a list not a single, right).
I’ve been using this documentation to lead myself here:
(I’m very, very aware this code doesn’t work. Very.)
if ( have_posts() ) { // If the category page is a top level category // display links to the child categories // else (It's a child category) // display each post in the child category $category = get_category( get_query_var( 'cat' ) ); $cat_id = $category->$cat_ID; $the_query = new WP_Query( array( 'category__in' => $cat_id ) ); echo "Cat ID: " . $cat_id; // null? Wtf? while ( $the_query->have_posts() ) { $the_query->the_post(); get_template_part( 'template-parts/content/content', get_theme_mod( 'display_excerpt_or_full_post', 'excerpt' ) ); } } else {}
If I had pages that were in a top-level category, It would list those.
How would I do this backwards – If it’s a category that is a top-level category, list the names of the subcategories that belong to ‘this’ category. Once I click that, I’m to the list of ‘lessons’Any and all help is appreciated.
Thanks.
- The topic ‘Help with site hierarchy’ is closed to new replies.