Skip to content

Instantly share code, notes, and snippets.

@thecodepoetry
Last active December 22, 2017 12:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thecodepoetry/62f446949deb13789dcf to your computer and use it in GitHub Desktop.
Save thecodepoetry/62f446949deb13789dcf to your computer and use it in GitHub Desktop.
Login logout link The7 topbar menu
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 );
@thecodepoetry
Copy link
Author

Add this code in child theme functions.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment