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 trial

WordPress

Chris Howell
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Chris Howell
Python Web Development Techdegree Graduate 49,702 Points

WordPress creating custom submenu

I created a function that basically uses 1 "Master Menu" then uses the wp_filter_objects function to build out I guess you could call a strictly child menu of whatever parent im clicked on that will be applied in my "Theme Locations" Secondary Menu Location.

So my question is: If I now have a variable that is storing an Array of Objects that contain all the data of each of these "child" menu items. Is there a built-in WordPress function I can use that would take an array of menu item objects and print out this menu?

Or maybe I just need to build a custom walker for it too?

Time for some rest, my brain is toast! :)

1 Answer

If I understand you correctly, then what you are attempting to do is make a drop-down submenu that gives columns for the subpages, correct? If so, then you could use CSS to mimic it, or you will need to define a custom menu and tap into the walker class. You may want to reverse-engineer a plugin that gives you some limited functionality to this end to see how it was coded.

Some CSS code would look like this:

/*
-- Responsive Column Dropdown Sub-Men --
*/

.nav-menu .menu-item:hover > .sub-menu {
    left: auto;
    opacity: 1;

/*------CUSTOM CODE - COLUMN DROP DOWN MENU--------*/
    display: inline-flex;
    flex-wrap: wrap;
    position: absolute;
    left: 5%;
    margin: 0 auto;
    justify-content: center;
    width: 90%;
    background-color: #fafafa;
    padding: 0px 50px 10px;
}   



@media only screen and (max-width: 1139px) {
    .nav-menu .menu-item:hover > .sub-menu {
        left: 7.5%;
        width: 85%;
    }
}


@media only screen and (max-width: 1023px) {
    .nav-menu .menu-item:hover > .sub-menu {
        left: 5%;
        width: 90%;
    }
}
Chris Howell
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Chris Howell
Python Web Development Techdegree Graduate 49,702 Points

Well, not exactly a drop down menu. I looked around and really couldn't find what I was after, but after playing around in my Functions.php for awhile I moved it over to into its own plugin. Right now it does what I need it to do, but i do need to test it some more and more than likely could use more logic.

Haven't had a chance just yet, it is Finals weeks. ;)