How can i put a login/create account link in the menu or header?
Hi jaliisah,
You can add by adding this code in your child theme’s functions.php file:
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 == 'avia') {
$items .= '<li class="menu-item"><a href="/wp-login.php?action=logout">Log Out</a></li>';
}
elseif (!is_user_logged_in() && $args->theme_location == 'avia') {
$items .= '<li class="menu-item"><a href="/wp-login.php">Log In</a></li>';
$items .= '<li class="menu-item"><a href="/wp-login.php?action=register">Register</a></li>';
}
return $items;
}
Let us know if this helps.
Best regards,
Nikko
That helped! Many thanks!
Hi,
Great, I’m glad that Nikko could help you out. Please let us know if you should need any further help on the topic, or if we can close it.
Best regards,
Rikard
You can close it Thank you again.
Hi,
Thanks for letting us know, I’ll close this thread for now then. Please open a new thread if you should have any further questions or problems.
Best regards,
Rikard