How To Add WP Login Link to Your Navigation Menu Automatically


Sponsored Links




WP Loginout Functions - Cow

WP Loginout Functions - Cow

I will show you easier tutorial add WP login Link to Your Navigation Menu Automatically. We only needed to some function to our functions.php and WP Login link will be automatically added into our WordPress Navigation Menu.

Description About wp_loginout()

Displays a login link, or if a user is logged in, displays a logout link. An optional, redirect argument can be used to redirect the user upon login or logout.

First, open your functions.php and add this code

add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);
function add_login_logout_link($items, $args) {

        ob_start();
        wp_loginout('index.php');
        $loginoutlink = ob_get_contents();
        ob_end_clean();

        $items .= '<li>'. $loginoutlink .'</li>';

    return $items;
}

That’s it, now you menu navigation will be added wp_loginout() automatically. More details about what going on this code you can read it here

Function Reference:

http://codex.wordpress.org/Function_Reference/wp_loginout

Subscribe to Full RSS Feed

RSS FeedIf you thing this article useful, please consider subscribing to our RSS Feed or e-mail updates and stay updated with us. You can also follow @WPTricksNet on twitter for latest updates.

About WP Tricks

We are WordPress Family, we collected and writed useful tips and tricks for you WordPress. We share it for you...

Related Tips and Trick from Local Data and on The Net


2 Responses to How To Add WP Login Link to Your Navigation Menu Automatically

  1. Pingback: Tweets that mention How To Add WP Login Link to Your Navigation Menu Automatically # WordPress Tricks & Tips -- Topsy.com

  2. Pingback: How to Add a Search Form on Navigation Menu Automatically | WordPress News Wire

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>