Created
March 1, 2017 21:11
-
-
Save mojenmojen/70b1fccff09da74234f392aec3c269f8 to your computer and use it in GitHub Desktop.
Add login/logout links to WP menus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment