WordPress output login and logout link tags: WP_ loginout

WordPress template tags WP_ Loginout is used to output login and logout links, WP_ Loginout () detects the user login status and outputs the corresponding link according to the user login status.

wp_loginout( string $redirect = '', boolean $echo = true )

Function parameters


String value, null by default

Provide a URL, when the user logs in or logs out, jump back to this URL, and generally provide the URL of the current page


Boolean value, default value: true

Whether to output the link. If it is false, only the result will be returned without output.

Examples of function usage

After login or logout, jump back to the home page of the website

<p><?php wp_loginout( home_url() ); ?></p>

If you are on the article page, log in or log out and jump back to the current page

<p><?php wp_loginout( get_permalink() ); ?></p>

No matter which page the user logs in or logs out, it will return to the current page

<p><?php wp_loginout( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); ?></p>

Extended reading

wp_ The loginout() function is located at: WP includes / general- template.php

Related tags:

  • is_ user_ logged_ in()
  • wp_ login_ form()
  • wp_ logout()
  • wp_ register()
  • wp_ login_ url()
  • wp_ logout_ url()
  • wp_ lostpassword_ url()
  • wp_ registration_ url()
Related Article
WordPress comment date tag: comment_date

WordPress template tags comment_ Date is used to output the date of a comment, usually in a custom comment template. Read more

WordPress comment summary tag: comment_excerpt

WordPress template tags comment_ Excerpt is used to output the summary of comments. The default output is 20 characters. It Read more

WordPress comment time tag: comment_time

WordPress template tags comment_ Time is used to output the publishing time of the current comment, which is the same Read more

WordPress RSS format comment author name tag: comment_author_rss

WordPress template tags comment_ author_ RSS is used to output the comment author name in RSS format, which has no Read more

Leave a Reply

Your email address will not be published. Required fields are marked *

To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image