add_filter( 'wp_nav_menu_top-menu_items', 'add_loginout_link', 10, 2 ); function add_loginout_link( $items, $args ) { if (is_user_logged_in()) { $items .= '<li class="menu-item"><a href="'. wp_logout_url() .'">Log Out</a></li>'; } elseif (!is_user_logged_in()) { $items .= '<li class="menu-item"><a href="'. site_url('wp-login.php') .'">Log In</a></li>'; } return $items; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter