Coolest Guides on the Planet

coolest guides on the planet

Coolest Guides On The Planet

  • Home
  • macOS
  • WebDev
  • All Posts
  • Contact

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

April 23, 2014 3 Comments

You can tack on the end of an existing WordPress menu the 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

function add_login_logout_link( $items, $args  ) {
	if( $args->theme_location == 'primary' ) {
	        $loginoutlink = wp_loginout('index.php', false);
	        $items .= '<li">'. $loginoutlink .'</li>';
			return $items;
	    }
	    return $items;
}
add_filter( 'wp_nav_menu_items', 'add_login_logout_link', 10, 2 );

If you need to style the additional menu item, just add a CSS class into the <li> tag.

theme-menu-locations

The key thing is the theme location value needs to be set  – normally themes will have primary and secondary and maybe tertiary menus.

Now if you are logged into the site the link will say logout and if you are logged in the site will say login.

login-logout-menu

Cats: WordPress

Tags

3gs 10.6 apache backup baseband boot clean urls cpanel css curl custom database drupal el capitan git Google image instadmg ios iphone jailbreak keys lion mac macos mojave macos sierra menu mysql OSX panda php phpmyadmin private public redirect redsn0w remote rsa SEO shell ssh terminal unstoppables upgrade urls

Donate a Beer to the Coolest Guides

Get Beaver Builder Now!

Discuss

3gs 10.6 apache backup baseband boot clean urls cpanel css curl custom database drupal el capitan git Google image instadmg ios iphone jailbreak keys lion mac macos mojave macos sierra menu mysql OSX panda php phpmyadmin private public redirect redsn0w remote rsa SEO shell ssh terminal unstoppables upgrade urls
Get DesktopServer

Lynda

Lynda.com Online Training Videos

TreeHouse

smlinks

Learn WordPress
osx-modify-shell-path

How to Add to the Shell Path in macOS Big Sur and Catalina using Terminal

October 19, 2019

virtual-hosts osx 10.10 yosemite

Set up Virtual Hosts on macOS Catalina 10.15 in Apache

October 19, 2019

Installing Homebrew on macOS Catalina 10.15, Package Manager for Linux Apps

October 18, 2019

Where is the bash shell in macos Catalina?

October 12, 2019

Refine your search

  • All
  • Modules
  • Themes
  • Documentation
  • Forums & Issues
  • Groups

RSS ars technica

  • OpenAI feels “burned” by Apple’s crappy ChatGPT integration, insiders say
  • Desperate Trump taps "Tim Apple," Jensen Huang, Elon Musk to attend Xi summit
  • Court rules Trump's 10% tariff is just as illegal as the tariff it replaced
  • Which Macs are suffering from shortages—and where are things getting worse?
  • Mac mini starting price goes up to $799, may be hard to get for "months"

RSS mac surfer

  • Apple Registers GenAI Subdomain Ahead of WWDC
  • Ben Stiller, Mike Judge Team for Apple TV Comedy
  • Apple Asks Supreme Court to Review Epic Contempt Ruling
  • Apple TV to Broadcast MLS Game on iPhone 17 Pro
  • OLED MacBook Pro Display Production Back on Track

Donate

Copyright © 2026· Neil Gee - All Rights Reserved - Hosted by Runcloud

Copyright © 2026 · gee on Genesis Framework · WordPress · Log in