Adding a Site Login/Logout Link to an existing Menu in WordPress

Add Login Logut To Menu

You can add on to the end of an existing WordPress menu a site login/logout link. The WordPress menu must be registered and have a theme location, this will not work with custom menus. This needs to be added to your theme functions.php file add_filter( ‘wp_nav_menu_items’, ‘themeprefix_login_logout_link’, 10, 2 ); function themeprefix_login_logout_link( $items, $args ) { if(…

Read More

Add Menu Items at the start or end or in a certain place with wp_nav_menu_filter

Add Menu Item In Place

wp_nav_menu_filter allows you add items at the end of a menu in WordPress but what about adding an item at the start of a menu or in a specific place. add_filter( ‘wp_nav_menu_items’, ‘prefix_add_menu_item’, 10, 2 ); /** * Add Menu Item to end of menu */ function prefix_add_menu_item ( $items, $args ) { if( $args->theme_location…

Read More