Home » Functions » wp_loginout

The WordPress function wp_loginout is used to display login and logout links. This function generates the HTML code for the link that leads to the login page if the user is not logged in, and the link to the logout page if the user is already logged in. The links are displayed according to the user’s login state.

This function is mainly used in the WordPress themes to display the login and logout links. It’s also useful for the developers who want to customize the login and logout links on their website.

Here is an example usage code for wp_loginout:

   $loginout_text = wp_loginout( '', false );
   echo $loginout_text;

In this example, the wp_loginout function is called, and the generated HTML code is stored in the $loginout_text variable. Then, the $loginout_text variable is echoed to display the login and logout links on the website.

The first parameter of the wp_loginout function is the link text. If it’s empty, the function will use the default link text for the login and logout links. The second parameter is the ‘echo’ parameter, which determines whether the function should output the HTML code or return it as a string.

Overall, wp_loginout is a useful WordPress function for displaying login and logout links on a website.

Learn More on WordPress.org

WordPress snippets using the wp_loginout function

Register an account to save your snippets or go Pro to get more features.