How to Set a WordPress Menu Link to Open in a New Tab
I’ve got a client with a custom nav menu link pointing to a third-party service. He wanted that custom link to open in a new tab, and I realized I didn’t know how to do it.
Fortunately, opening a menu link in a new tab is easy, and it’s available in WordPress core—no plugins or custom code required. The linked article gives a perfect visual guide to it.
The solution is interesting for a couple of reasons:
- It’s another of many examples where something perfectly easy is hidden thanks to the “Screen Options” interface.
- It’s an example where something useful is available through the backend Menu interface, but not the Customizer menu interface.
Two last thoughts: hardcoding “open this link in a new tab” is not great for UI/UX generally, since you’re making a decision for the user—proliferate tabs—that she should either be able to make herself (if she knows her browser), or that she may not want made. Also, accessibility guidelines stipulate that links you’re going to set to open in a new tab should include an indication that you are doing so, like the icons Wikipedia uses. So just saying, don’t go crazy.
Image credit: Yandle