WordPress login and logout for custom template

Login and logout link (way – 1):

[code]

<code><?php wp_loginout();?></code>

[/code]

Login and logout page with custom links (way – 2):

[code]
<?php
if ( is_user_logged_in() ) {
echo ‘<a href="’.wp_logout_url().’" title="Logout">Log out of my site</a>’;
} else {
echo ‘<a href="’.wp_login_url().’" title="Login">Log in to my site</a>’;
}
?>
[/code]

Login and logout page with custom links and redirect to previous page (way – 3):

[code]
<?php
if ( is_user_logged_in() ) {
echo ‘<a href="’.wp_logout_url( get_permalink() ).’" title="Logout">Log out of my site</a>’;
} else {
echo ‘<a href="’.wp_login_url( get_permalink() ).’" title="Login">Log in to my site</a>’;
}
?>
[/code]

Custom login and logout pages with custom links (way – 4):

[code]
<?php
if ( is_user_logged_in() ) {
echo ‘<a href="’.wp_logout_url( home_url() ).’" title="Logout">Logout</a>’;
} else {
echo ‘<a href="’.get_permalink( 22 ).’" title="Login">Login</a>’;
}
?>
[/code]

One Reply to “WordPress login and logout for custom template”

  1. It’s hard to find your blog in google. I found it on 12 spot, you should build quality
    backlinks , it will help you to increase traffic.
    I know how to help you, just search in google – k2 seo tips and tricks

Leave a Reply

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


*