Last active
December 22, 2017 12:52
-
-
Save thecodepoetry/62f446949deb13789dcf to your computer and use it in GitHub Desktop.
Login logout link The7 topbar menu
This file contains hidden or 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
function the7_login_logout_link( $items, $args ) { | |
if( $args->theme_location == 'top' ) { | |
$loglink =""; | |
if ( ! is_user_logged_in() ) | |
$loglink .= '<li class="menu-item menu-item-type-custom menu-item-object-custom"><a href="' . esc_url( wp_login_url() ) . '"><span class="menu-item-text"><span class="menu-text">Login</span></span></a>'; | |
else | |
$loglink .= '<li class="menu-item menu-item-type-custom menu-item-object-custom"><a href="' . esc_url( wp_logout_url() ) . '"><span class="menu-item-text"><span class="menu-text">Logout</span></span></a>'; | |
$items = $loglink.$items; | |
} | |
return $items; | |
} | |
add_filter( 'wp_nav_menu_items', 'the7_login_logout_link', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this code in child theme functions.php