Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialChris Howell
Python Web Development Techdegree Graduate 49,702 PointsWordPress Genesis Conditional Secondary Navigation
I have been watching the WordPress Genesis Framework videos and playing around with a child theme of Genesis. I was curious if anyone has played around with making Conditional Menus?
Jesse Petersen if you have any advice or maybe a future video that would cover how to make our own Conditional Menus?
Ideally Id like to be able to make my site have a primary navigation that only a single depth, then have a secondary menu that dynamically changes based off the links clicked on the primary menu or changes based on page you are on. I seen the Genesis Extender Plugin has this feature built in, but Id rather not spend that kind of money, plus learning how to implement and customize my own would in my Genesis child theme would be awesome.
3 Answers
Sridhar Katakam
Courses Plus Student 32 PointsYou might want to take a look at http://www.billerickson.net/genesis-subpages-as-secondary-menu/.
Sridhar Katakam
Courses Plus Student 32 PointsIt is also possible to programatically assign different menus in Secondary Navigation Menu location in Genesis.
Here's an example: https://sridharkatakam.com/conditionally-assigning-different-menus-in-secondary-navigation-menu-location-in-genesis/
Disclaimer: That is my site and paid membership is needed to access full content.
Chris Howell
Python Web Development Techdegree Graduate 49,702 PointsSo I think there are a few ways of coding this out.
I can either make multiple menus within WordPress and name them accordingly, ex: Primary Menu, AnyName Menu, etc. Where AnyName Menu would be a list of some type of categories for a certain menu item in the Primary Menu. Like if "Blog" was in the Primary Menu then AnyName I would probably call it Categories Menu which would contain obvious categories for Blogs. Then Anytime Blog was clicked on that "Categories Menu" would be pulled up dynamically.
OR
I know there has to be a way to just make a Primary Menu with a hierarchy of sub items. Then I would use what? set Depth to 1 in the args, and code out something in the functions.php file to dynamically grab the Parent Menu item and then loop through the children into that secondary menu?
To me the first options, which seems to be the option people are implementing into plugins: Making many menus and then hard coding conditionals in their functions.php seems like it would be performance heavy and generally not a good practice. I think the second option would be "easier" to manage in the admin area because creating that hierarchy is drag and drop. But I am not experienced enough to actually know how I should code this out.
Chris Howell
Python Web Development Techdegree Graduate 49,702 PointsChris Howell
Python Web Development Techdegree Graduate 49,702 PointsThanks for the link, I hadn't found this one when I searched around. I will have to play around with his code a bit.