Created
April 30, 2013 21:52
-
-
Save cobbman/5492226 to your computer and use it in GitHub Desktop.
WordPress: Add login/logout links to WordPress functions.php
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 login/logout links to the footer navigation | |
// Put this in functins.php | |
// This will filter through the menu items and look for the footer-menu. | |
// Then append login/logout links to the end | |
function add_loginout_menu_to_footer( $items, $args ) { | |
if ( is_admin() || $args->theme_location != 'footer-menu' ) // only add login/out items to the footer menu | |
return $items; | |
$link = wp_loginout( $redirect = home_url(), $echo = false ); // use wp_loginout() to return the correct login OR logout link strings | |
// append our new list item to the current menu list items and return it | |
return $items .= '<li id="log-in-out-link" class="menu-item menu-type-link">'. $link . '</li>'; | |
} | |
add_filter( 'wp_nav_menu_items', 'add_loginout_menu_to_footer', 49, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment