What's WP
Find Everything Related to WordPress - Best Tutoriasl on WordPress!
How to Add Login and Logout Links to WordPress Menu

How to Add Login and Logout Links to WordPress Menu

Being the owner of a WordPress site, you probably have executed the endless strategies for increasing the conversion rate and driving online traffic. These may include starting the A/B test, providing valuable information and ensuring the professional appearance. In fact, there is another important practice that you need to adopt, which is offering an easy login/logout option for your visitors in different sections of your WordPress site. This can give people a great website browsing experience with the best convenience.

In this article, we’d like to discuss the methods to add a login/logout link to WordPress menu, as well as when you should do this.

When Do You Need to Add A Login/Logout Link?

Once you have driven a remarkable number of daily visitors to your site, you must want them to explore your offerings and execute the desired Call to Action. For instance, if you own a fashion apparel website, you must hope your visitors can login to your site and purchase products. So, in order to execute the Call to Action, it is imperative that your visitors can find the login channel easily. Vice versa, if they finish the actions, they can leave your site securely by logging out the account.

That being said, you must add a login/logout link in your WordPress menus so that the visitors do not need to search for ways to enter or leave your site in a safe way. Note that the main menu tab and sidebars are some common sections where you can add the login/logout link for effective results.

How to Add A Login/Logout Link by Inserting Codes

Coding has always been the preference of developers who are conscious about the performance of their websites. For this reason, if you want to add a login/logout option in your WordPress menus without compromising the loading speed of your site, here is the procedure.

First of all, you need to dig into your control panel and find the functions.php file from the File Manager. Then, you have to open the file using an advanced text editor and insert the following code.

if(!function_exists( 'add_login_logout_menu')) 
    function add_login_logout_menu($items, $args)
        if(is_admin() || $args->theme_location != 'primary') return $items; 
        if( is_user_logged_in( ) )
            $link = '<a href="' . wp_logout_url('/index.php') . '" title="Logout">' . __( 'Logout' ) . '</a>';
            $link = '<a href="' . '/wp-login.php' . '" title="Login">' . __( 'Login' ) . '</a>';

        return $items .= '<li id="login_logout_menu-link" class="menu-item menu-type-link">'. $link . '</li>';

add_filter( 'wp_nav_menu_items', 'add_login_logout_menu', 20, 5);

Once you add the code mentioned above, you should make sure that the theme location is primary, secondary or tertiary. Then, save the file to implement the changes.

How to Add A Login/Logout Link by Using Plugins

If you do not want to involve the need for codes, you can opt for an effective plugin that adds a login/logout link to your menu with ease. We have listed the top 2 options in the following. Thus, all you need to do is to install one of the following plugins on your WordPress site through the admin panel, and then configure the settings to add the links.


Website: https://wordpress.org/plugins/login-logout/

This is an efficient tool that adds a login/logout widget in your WordPress site, with which you can allow the existing visitors to login and new visitors to register their presences easily. Even, you can determine the text for login, logout and register options.


My Login Logout Plugin

Website: https://wordpress.org/plugins/my-loginlogout/

The WordPress plugin allows you to insert the login/logout link in the default themes, custom themes or menu-bar. This tool offers the flexibility of redirecting the visitors for logging in or logging out conveniently.

Within the settings page, you also get an option to configure a custom URL after logout. For instance, when people log out their accounts, they can be redirected to your contact page, homepage, or the hottest blog post. Even, you can decide where you want the links to be displayed in the primary menu or secondary menu.

My Login Logout Plugin


Susan Rose is a freelance writer who has a deep knowledge about WordPress. She loves everything related to website building since the freshman year at Christopher Newport University, and loves to share her experience with people all over all the world. In the daily life, Susan loves detective novels as it can train her logical thinking and creativity.