I’ve ran into a problem using a custom WordPress menu that I can’t seem to solve, so after doing a lot of searching the web & failing to fix this over the past few days, I’ve decided to see if anybody here on StackOverflow can help.
Please note: I would use a Walker function for this but I’m too far gone with the code right now and the way the design works I’m having to build the menu this way.
My snippet for my dropdown: http://pastebin.com/8Stfs90c (would post but it would crucify the screen).
Iâm having trouble with the 3rd level of my dropdown menu. In this image: http://s13.postimg.org/lxhslt0lz/image.png you can see that thereâs a <li></li>
that Iâve highlighted (Pages, About Me, About Us). The structure is as follows
Pages (Parent)
About Me (Parent: Pages)
About Us (Parent: About Me)
And these are fine, BUT when it goes to the third dropdown, it cuts of the <li>
and leaves the rest of the Pages children and puts them into a separate container and not the <li>
for Pages.
So it should work like so:
Pages (Parent)
About Me (Parent: Pages)
About Us (Parent: About Me)
Right Sidebar (Parent: Pages)
Left Sidebar (Parent: Pages)
Our Process (Parent: Pages)
And all though it may look like this on the dropdown (visually), as you can see in the code it isnât represented by this. I think the problem Iâm having is the checks Iâm doing for closing the </li>
is wrong. Iâve had this problem for a few days and I just can’t seem to fix it. I was going to post this on the WordPress based forum but it’s more of a PHP error than anything else.
Hereâs a quick screenshot of me hovering over the elements that should be in Pages: http://s23.postimg.org/ef4ame6m3/image.png – as you see theyâre separated from the <li>
.
To replicate this what I’ve done is just created a menu structure in WordPress and used the code that’s in the snippet (basically I just pasted it into the index.php file) to show how it’s being represented.
I really hope somebody can help with this as it has been driving me mad and put a holt on my project for the past few days.
Apologies for the links above, I would post them directly in (screenshots & code) but I didn’t want to take away from the actual problem.
If somebody does manage to provide me with the solution I’d be more than happy to buy you a virtual coffee or two!
Out of curiosity, I could be missing the point, is there a reason why would not want to use wp_nav_menu() to handle all of this?
Ex below would output the correct structure for you to theme as your screenshot if applied in your context?
Thanks.
Had a quick look at the code, I suppose line 100-130 are dealing with the third dropdown. Actually whats happening is you already have an ol on line 105, then its again being called through the loop on line 122.
I think the problem is on line 128 you have to remove ol from the end and create a new condition just for this.
Sorry if i am not being of any help but its really hard to picture the whole code in mind without seeing it. If you are really stuck send the ftp details in chat and i can have a look.
Hi There try this css code to create multiple Nested menu create.
WP code for menu in header.php
CSS Code Add in your style.