◦ Comprehensive security
◦ 24/7 support
WordPress Guide → Build → One Click URL Logout
How to create a one-click logout link in WordPress
Giving users a fast and easy way to log out improves your site’s usability—especially for membership sites, client dashboards, or online courses. Instead of making people dig through menus or admin bars, you can offer a direct logout button that works instantly.
Let’s walk through how to add that one-click logout link to your WordPress site, along with visibility settings, plugin options, redirect customization, and a bonus method for shortcodes and widgets.
Get fast, reliable hosting for WordPress
Power your site with the industry’s fastest, most optimized WordPress hosting
Why add a one-click logout link?
A single-click logout link improves user experience and streamlines site navigation. It’s especially useful for:
- Membership sites, LMS platforms, or ecommerce accounts
- Portals or dashboards where users expect an obvious “log out” option
- Making your interface more user-friendly for mobile visitors
By default, WordPress doesn’t add a logout option to your navigation menu, so you’ll need to insert the link manually or with a plugin.
1. Use a logout URL in a custom menu link
The simplest and most direct way to log a user out is with a specific URL:
https://yourdomain.com/wp-login.php?action=logout
Here’s how to add that link to your navigation menu:
- In your WordPress dashboard, go to Appearance > Menus.
- Select the menu you want to edit (e.g., “Primary Menu”).
- In the left-hand column, click Custom Links.
- In the URL field, enter:
https://yourdomain.com/wp-login.php?action=logout
(Replace yourdomain.com with your actual site URL.) - In the Link Text field, type something like Logout or Sign Out.
- Click Add to Menu.
- Drag the link into position if needed.
- Click Save Menu to apply the change.
Clicking this link logs the user out and takes them to the WordPress login screen (wp-login.php). From there, they can log back in if needed.
2. Show the logout link only to logged-in users
You probably don’t want a logout link visible to people who aren’t signed in. To do that, you’ll need to add a condition.
Use a plugin
Here are three beginner-friendly options:
- Theme My Login – This plugin handles login, logout, and registration links automatically. It also hides or shows them based on user status.
- User Menus by Code Atlantic – Adds a “logged-in users only” setting to any menu item.
- Block Visibility – For block-based themes, this lets you control block visibility based on whether the user is logged in or not.
Use custom code (optional)
For developers, you can control this with PHP in your functions.php file or a custom plugin:
add_filter('wp_nav_menu_items', 'conditionally_hide_logout', 10, 2);
function conditionally_hide_logout($items, $args) {
if (!is_user_logged_in()) {
$items = str_replace('Logout', '', $items);
}
return $items;
}This removes the logout link for users who aren’t signed in.
3. Use a plugin to add a logout link
Plugins offer more control, especially if you want a logout link in multiple places (like headers, sidebars, or footers) or want to customize behavior.
Popular plugin options
- Theme My Login: Adds login/logout links to your menu and handles redirects. Great for sites with multiple user roles.
- WP Logout Redirect: Lets you define a custom redirect URL after logout. Simple but powerful.
- Redirect to homepage or custom page
- Works with native WordPress logout link
- Starting at: Free
- User Menus by Code Atlantic: Adds login status and role-based visibility to any menu item.
4. Redirect users after logout (optional but useful)
If you’d rather send users somewhere more helpful than the default login screen, you can modify the logout URL.
Use this format:
https://yourdomain.com/wp-login.php?action=logout&redirect_to=https://yourdomain.com/custom-pageReplace the second URL with your preferred destination. You could redirect to:
- A “You’ve been logged out” message page
- Your homepage or storefront
- A thank-you page or survey
Plugins like WP Logout Redirect make this even easier without touching the menu URL.
5. Test your logout link for functionality and UX
Make sure your logout link works properly and delivers a smooth experience.
Steps to test:
- Open your site in an incognito/private browser window.
- Log in as a regular user.
- Click your new logout link.
- Confirm that it logs you out and redirects to the correct page.
If you’re using a plugin for visibility, log out and make sure the logout link disappears for visitors.
Bonus: Add a logout button with shortcode or widget
For more flexibility, you can create a logout button using a shortcode and place it in a widget or post.
Create a logout shortcode:
Add this to your functions.php or a small plugin:
function wp_custom_logout_link() {
return '<a href="' . wp_logout_url(home_url()) . '">Logout</a>';
}
add_shortcode('logout_link', 'wp_custom_logout_link');Then use [logout_link] anywhere shortcodes are allowed—including sidebar widgets (with a plugin like Shortcode Widget) or Elementor blocks.
Use a block-based button:
If you’re using the block editor, add a Button Block and paste this URL:
https://yourdomain.com/wp-login.php?action=logout
Label it Log Out and style it however you’d like.
Next steps for adding a logout link in WordPress
Adding a one-click logout link gives users an intuitive, easy way to exit your site—no digging through admin bars or hidden options required.
Start by adding the logout URL directly to your menu. From there, enhance it with login conditionals, plugins, or custom redirects for better control.
Ready to upgrade your WordPress experience? Professional hosting improves speeds, security, and reliability for a website and a brand that people find engaging and trustworthy.
Don’t want to deal with server management and maintenance? Our fully managed hosting for WordPress is the best in the industry. Our team are not only server IT experts, but WordPress hosting experts as well. Your server couldn’t be in better hands.
Click through below to explore all of our hosting for WordPress options, or chat with a WordPress expert right now to get answers and advice.
Additional resources
How to build a WordPress site →
A complete beginner’s guide that covers 9 key steps to a successful launch
Give your website the dark mode treatment (WordPress) →
Learn how to enable dark mode on your WordPress website to enhance user experience and reduce eye strain.
How to use WordPress Gutenberg blocks →
A complete beginner’s guide to Gutenberg blocks