Add a link in a new tab with the "Custom Link Menu New Tab" module
In a WordPress site, it often happens that certain links in the navigation menu need to open in a new tab. However, WordPress doesn't offer a simple, visible interface for managing this behavior directly from the menu settings. That's why we've developed the Custom Link Menu New Tab from WPMasterToolKit. This module adds a practical option for configuring the opening of custom links in a new tab, while automatically adding attributes such as rel="noopener noreferrer nofollow"
This enhances both the user experience and safety.
Which plugin can the "Custom Link Menu New Tab" module replace?
This module can easily replace dedicated plugins such as "External Links in New Window / New Tab or other similar extensions that add functionality for opening links in a new tab for menus.
Simplified management of personalized links
With the Custom Link Menu New Tabusers now have precise control over the opening of custom links in menus. Here's how it works:
- Checkbox added to menu parameters A new checkbox appears in the menu item editing options (only available for custom links).
- Save selected option If this option is enabled, it will be saved for this specific menu link.
- Automatic addition of attributes When the box is checked, the attributes
target="_blank"
andrel="noopener noreferrer nofollow"
are automatically added to the link, guaranteeing greater security and SEO compliance.
How do I use the "Custom Link Menu New Tab" module?
- Activate the Custom Link Menu New Tab from the WPMasterToolKit parameters.
- Go to Appearance > Menus in the WordPress dashboard.
- Add or modify a personalized link in your menu.
- In the element parameters, a new checkbox entitled "Open link in new tab and add rel='noopener noreferrer nofollow' " will appear. Check it if you want the link to open in a new tab.
- Save the menu to apply the changes.
The module does all the work in the background: it saves your choice and automatically applies the necessary attributes.
Technical choices behind the module
Optimized performance
In keeping with the WPMasterToolKit philosophy, we've designed this module so that it doesn't load no unnecessary resources. If the module is not activated, it is not loaded into WordPress, which limits its impact on your site's overall performance.
Using WordPress filters and actions
We used native WordPress hooks to ensure maximum compatibility with other extensions and themes:
wp_nav_menu_item_custom_fields
This filter allows us to add the checkbox directly to the menu item parameters.wp_update_nav_menu_item
This action saves the value of the checkbox when the menu is saved.nav_menu_link_attributes
This filter is used to automatically add the attributestarget="_blank"
andrel="noopener noreferrer nofollow"
to the relevant custom links.
Enhanced safety
Attributes rel="noopener noreferrer nofollow"
automatically added protect your site from potential vulnerabilities linked to external links opened in a new tab, while respecting SEO best practices.
Conclusion
The module Custom Link Menu New Tab is a simple yet powerful solution for managing links in WordPress menus. Whether you're looking to enhance the user experience or strengthen your site's security and SEO, this module is designed to meet your needs while being lightweight and easy to use. By activating this module via WPMasterToolKit, you can say goodbye to additional plugins while retaining total control over your menus.