First time I have used stack-overflow, please forgive me if I make a faux pas.
I am new to php, and am currently building my first WordPress Theme. I want to have several separate sections of the website with a side-bar menu that displays links only to the other pages in the section you are in. For example if you are viewing post 1 of section A the side menu would display links to posts 2, 3, and 4 of section A. The menu would be the same on all posts of section A. Section B would have a different menu displaying it's posts. The site will require about 25-30 different sections.
I was hoping to do this with Categories, but am certainly open to other options. I have attempted this a few different ways to no success. I feel this should be simple, and I am just missing something basic.
I think my problem is calling the information necessary I started it as:
<?php if (is_category('tanzania')) : ?>
<?php wp_nav_menu(array(
'theme_location' => 'tanzania-menu'
)) ?>
<?php elseif (is_category('safrica')) : ?>
<?php wp_nav_menu(array(
'theme_location' => 'safrica-menu'
))
<?php else : print('Nope.'); ?>
<?php endif; ?>
This did not work at all (something I am sure is super obvious to you all). It displays each menu properly but only at the category overview page. Once you click on a link in the menu it takes you to the post's perma-url and the menu vanishes. I figured out that this is because the in_category only sees pages in the /category/ directory, but am unsure how to fix it.
The other issue is having my sidebar.php be so long. Using the above method I basically had a huge switch ~80 lines long. I am not sure if that is bad, but it seems... unwise. Everytime I tried to shrink it down, I ended up with it not working at all.
Thank you for your help with this, WP has been quite the learning curve.
single.php
and another loop in thesidebar.php
that only loops through current category (but does not include the currently viewed post in the list). – William Patton