How to make the navigation menu creation experience better in your WordPress block theme

screenshot of the menu editor screen in WordPress

Want to skip to the solution? Click here to go to the TLDR.

I am not going to lie: I love creating block themes with WordPress.

It’s kind of crazy how easy a lot of things now are from a theme developer’s perspective. To be completely honest, I’ve now redone my main website as well as the Sports Bench WP website twice each this year using full site editing, and the process from build to live has been less than two weeks each time. And those are not small websites.

And once I sat done and solely focused on building the Semplice Monospazio theme, it took roughly a week to complete and send off to the theme directory for review.

But there is one trouble spot that I have found for both developers and users alike: creating navigation menus.

While there is a much talked about navigation block, I have definitely had trouble creating menus through it. You first have to click just right to be able to add a new menu item, and then adding a page or category to the menu can be a challenge, especially if you have a lot of content that has lot of the same words in the title.

I was able to see this a mile away before I moved my main website over to a block theme and was able to create the new menus in the old menus screen before the switch. But this second redesign required menu changes as well, and, well, using the navigation block wasn’t going to cut it.

But I was able to find the following line of code that can bring that old screen back.

This line of code is actually a way for all themes, whether block or “legacy”, to signal that it supports navigation menus. And in fact I came across this in the docs for the regular PHP themes, not for block themes.

But it works the same. Adding that line of code brings back the “Menus” item in the “Appearance” menu. And from there I was able to create the new menus and then select them when editing the various navigation blocks inside the theme. Who knew?

So if you’re creating a block theme for a client or even just for the WordPress theme directory or somewhere in between, it’s probably a really good idea to include that line of code in your functions.php file to make the menu creation experience better for your users.

Oh, and don’t get me started on the widgets screen. That’s another topic for another time.

Leave a Reply

Your email address will not be published. Required fields are marked *