WP Explorers Adapt theme: Add a submenu button
-
Hi. I have added the follow piece of code to the functions.php file. This adds a specific button to the main menu if the user is logged in, and another if he isn’t.
// Change menu button when logged in add_filter('wp_nav_menu_main-menu_items', 'menu_add_admin_buttons', 20, 2); function menu_add_admin_buttons( $items, $args ) { $btn_format = '<li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="%s">%s</a></li>'; if ( is_user_logged_in() ) { $btn = sprintf($btn_format, 'https://url1', __('Your profile') ); } else { $btn = sprintf($btn_format, 'https://url2', __('Log In') ); } return $items . $btn; }
How can I alter this a bit or copy it with changes, so it adds a SUBMENU button to one of my menu buttons, only if the logged in user is an ADMIN?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘WP Explorers Adapt theme: Add a submenu button’ is closed to new replies.