I've got a situation where I need to limit the top level menu items on a custom menu. The design only has room for 4 fixed width items, and I want to future proof it from displaying more.
Looking at Is there a way to limit the number of top level items in a custom menu?, the answer referred to using
Unfortunately, looking through the wordpress.org forums and various blog posts, I can only examples that add items, and nothing that removes them.
When I echo out
$items, I only receive a list of each menu item in it's full html. I'm not good enough with regex to figure out how to set a limit to stop after 4 items (and am not sure if that's actually possible with regex anyway).
I have also tried just using css to hide all remaining items through
overflow:hidden, but that also hides the dropdowns, so that isn't an option either.
Is there any way I can limit top level items through my custom