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.

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.