How to create a log in and log out link in WordPress

You are currently viewing How to create a log in and log out link in WordPress

If you would like to have a text link in WordPress that allows you to either log in or log out, follow these steps:

1. In WordPress, go to Appearance > Theme Editor.

2. On the right, select functions.php.

3. Scroll to the bottom of the page and copy and then paste the following lines of code:

4. At the bottom-left of the screen, press “Update File.”

In the above steps, you created a new function and a shortcode that executes the function. You will need to place the shortcode where you want to text link to appear. I recommend placing it on the footer. How you will do this depends on your website’s theme.

Copy and then paste the following shortcode where you want the link to appear:

[login_link]

Once you save your work, you will see an open padlock icon if you are logged in, or a closed padlock icon if you are logged out. Clicking the padlock icon will allow you to ether log in or log out.