Using this plugin you can use WordPress Conditional Tags to enable or disable menu items on the front-end. It works like ‘Widget Logic’ but for menu items.
PLEASE NOTE The conditions are PHP codes that are evaluated using PHP’s “eval” function, meaning anyone who has access to the Menu manager in WordPress can execute any code. Be mindful of who has access to the Menu manager.
You must insert conditional tags in the “Visibility” box in the menu item options form. You can use any PHP or WordPress functions to build crazy conditions and logics for menu items. For example, to hide the menu item on homepage you can set the visibility to:
Show the menu only to logged-in users:
Show the menu only to guest visitors:
To show the menu item based on user capability:
current_user_can( 'manage_options' )
- Upload the
menu-item-visibilitydirectory to the
- Activate the plugin through the ‘Plugins’ menu in WordPress
- Locate the ‘Menus’ item on the ‘Appearance’ menu
- While editing your menu item, you see another option: Visibility, input your logic and that’s it.
Contributors & Developers
“Menu Item Visibility Control” is open source software. The following people have contributed to this plugin.Bidragsydere
- Fix error handler in php8
- Improve error handling
- Better compatibility with outdated themes that don’t support WP 4.5
- Updated to use the new API in WP 4.5
- Fix JS error on Menus manager
- Revamp of how fields are added to WP UI, should prevent conflict with other plugins and themes.
- Possible fatal error prevention
- Fix compatibility with Menu Icons plugin
- Fix menu item edit screen styles
- Fix Customizer wiping out the Visibility value upon save
- Got rid of PHP notices in the admin area
- Updated Walker_Nav_Menu_Edit
- Gantry 4.0 compatibility
- implemented singleton pattern
- added the remove_visibility_meta function which cleans up the meta datas for deleted menu items
- Fixed a minor bug where unnecessary database rows in postmeta table would be created upon save
- fixed a bug concerning using quotes in conditions
- Compatibility with latest WordPress release
- Fixed a minor bug where conditions would also execute on the admin area