How to Add a Login/Logout Link to WordPress Menu

In this post, I will show you how to add a login / logout link to the your WordPress navigation menu. This code snippet automatically detects whether the user is logged in or not and display the login or logout link accordingly.

This is the very easy and simple code which will save tone of times from adding login/logoout link manually in menu bar.

Login-logout-menu

No plugin needed, add it to the theme’s functions.php file

Add the following code to your theme’s functions.php file and change the menu area name if you are not using “primary“. For WordPress 3.0 and up.

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

Recommended Posts:


Prem Tiwari

An engineer by profession and a passionate blogger by heart. Founder of FreeWebMentor.com (A Programming blog for beginners), Tech Speaker at various forums. A part from this he is an open source enthusiast, WordPress Lover, Blogger, SEO, and Growth Strategic.


Article Tags: , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.