Use wp_login_url()
function with get_permalink()
as a parameter, if a user is not logged in. Something like this:
<a href="https://wordpress.stackexchange.com/questions/210374/<?php echo wp_login_url( get_permalink() ); ?>" title="Login">Login</a>
And wp_logout_url
function with get_permalink()
as a parameter, if a user is logged in.
<a href="https://wordpress.stackexchange.com/questions/210374/<?php echo wp_logout_url( get_permalink() ); ?>">Logout</a>
EDIT: instead of using 2 different functions, you may use
<?php wp_loginout(get_permalink()); ?>
that displays a login link, or if a user is logged in, displays a logout link
Related Posts:
- Show login greeting above sub-menu links?
- Menu not updating for logged in users after redirect
- User registration followed by automatic login
- wp_nav_menu returns menu list in ascending order. How can I arrange the menu same as dashboard menu
- getting logged in user info (wp-load.php) from parent directory
- Unique icons next to each WordPress menu item
- Child page menu in sidebar
- Title Case WordPress Menu Items
- Secondary navigation menu on one page
- Remove class in nav_menu_link_attibutes filter
- WordPress Quick Question . How to Get Parent Link in Submenu in My Code
- Trying to store submenu items to render out after main menu
- Detecting classes, adding widgets, and adding divs in with a Nav Walker
- Problem with login form
- How to change menu order item
- Login to wordpress by clicking a link and specifying usernaname and password in url
- Custom Menus: dynamic highlighting problem with custom home link
- get_the_title() gets printed out twice
- Log in / Log Out Custom Button
- Add item to top of menu using a filter in functions.php
- Should `wp_login` be used since it’s deprecated?
- How to redirect users based on role and content of redirect_to?
- Change CSS based on is_user_logged_in
- Adding PHP in the menu
- Two menus show up
- How to display login form anywhere, when user isn’t logged in, without redirecting?
- How can I open up my administrative panel to everyone?
- Register a menu – Error Header
- How to style one item from main navigation?
- Show About and Contact Us page when they’re clicked in the top menu.
- New walker for walker_nav_menu to change inside container data
- Add data-id attribute to child page links
- Parsing Menu Items and Blog Posts
- Add login hyperlink to secondary navigation menu
- Automatically add images to a menu
- How can I add a new row in a separate database when someone registers via WordPress?
- Add value to new attribute inside WordPress menu items
- wp_nav_menu not working correctly in my underscores theme
- One account with multiple logins
- Lost in trying to create user database system
- Menu Items fail to save correctly, cause reset of related page metadata
- Dropdown menu for categories
- Menu Custom Data Attributes
- How to display different submenus?
- Get the name of menu item with wp_nav_menu
- Notice: Trying to get property of non-object
- Shortcode to log user into current URL
- How to use wp_nav_menu to create custom dropdown menu?
- How to modify mobile nav menu text in theme
- Output only links using wp_nav_menu()
- Get css class of menu item in custom menu structure
- How to add aria role and schema markup to custom walker container
- PHP getting error when trying to access WP-Admin Dashboard
- How can I use custom menus with a Bootstrap WordPress theme?
- Nav menu from plugin to theme
- Adding Additional Variables on Menus Page
- I installed WordPress locally now how do I login?
- If user is logged in not working
- Change homepage content if user is logged in – BuddyPress
- Extend Menu Walker Output
- Nav-Menu not showing up
- Custom navigation menu with awsAccordion
- how to add a div inside wp_page_menu
- How to correctly load a different version of main menu based on the user language in WordPress? Is it a good solution?
- Why in this WordPress theme I can’t see the Main Menu?
- Why can’t I add a custom image in my navigation?
- Remove submenu item from list
- conditional: if is page, and all subpages
- wp nav menu: show submenu below li item
- How to tell if a user has gone in and created a menu
- Dynamic Menu drops pages?
- Class for Selected Menu using wp_nav_menu
- is_user_logged_in returning nothing on custom page
- Remove the Tag from wp_nav_menu
- Menu not styling. New menus functionality giving me a headache
- Styling an “active” link outside of WordPress default menu
- How to create Loop code for Menu using WordPress?
- Hard-coding a shortcode as the last menu item in primary navigation?
- Dynamic menu with custom post types
- Help with accessing wp-admin page and resolving error messages
- Add class to ul and li in wp_na
- Nav Walker that shows only children and siblings of top level parent menu item
- how to changes mobile menu toggle breakpoint in WordPress
- How to display already created menus via php?
- Adding an Anchor Link to a wordpress menu using WPBakery Page Builder
- Providin exception to WordPress wp_nav_menu Custom CSS Classes
- Removing “There is no account with that username or email address.” error message in “/wp-login.php?action=lostpassword”
- Can’t log in to WordPress wp-admin after adding code to functions.php
- Adding markup to sub menu based on class
- Check if user had autologin & if so, logout
- Featured image in menu wordpres
- How to make only the valid active page of a multilevel menu active with – “.nav li.current-menu-item a”?
- Admin Panel 404 Error after login
- PHP warning – Use of undefined constant ‘FORCE_SSL_LOGIN’ ‘FORCE_SSL_ADMIN’ on wp-config.php
- Replace jQuery with PHP or CSS for Customized WordPress wp_nav_menu
- How to block specific user id in custom login form?
- Log out without confirmation request (nonce)
- dynamic php menu with hidden sub-categories only showing when the category name is clicked
- How to set Nav as a default menu in wordpress
- Having trouble creating two shortcodes, one for logged in user and one for visitors