Skip to content

Instantly share code, notes, and snippets.

@NiBow
Forked from larsmqller/gist:e8e4b10e5e2a8abddc59
Created March 18, 2016 10:50
Show Gist options
  • Save NiBow/dd92cda78357ba45a579 to your computer and use it in GitHub Desktop.
Save NiBow/dd92cda78357ba45a579 to your computer and use it in GitHub Desktop.

Revisions

  1. @larsmqller larsmqller created this gist Mar 18, 2016.
    11 changes: 11 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    // Login log out functionality in menu, add stuff to menu
    add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 );
    function add_loginout_link( $items, $args ) {
    if (is_user_logged_in() && $args->theme_location == 'top_nav') {
    $items .= '<li><a href="'. wp_logout_url() .'">Log Out</a></li>';
    }
    elseif (!is_user_logged_in() && $args->theme_location == 'top_nav') {
    $items .= '<li><a href="'. site_url('wp-login.php') .'">Log In</a></li>';
    }
    return $items;
    }