I would like to display a Login / logout link above menu as my theme doesn't have this feature.

Login/Register at right top corner and same it should show in mobile version as well.

I am using subscribe pro theme by HAPPYTHEMES. You can check the demo version here: https://www.happythemes.com/demo/?theme=subscribe-pro

  • Create the child theme and use wp_loginout() function in the corresponding place. – Max Yudin Aug 25 '18 at 14:55

If your theme adheres to WordPress standards the menu is generated with a call to wp_nav_menu. This function has a filter that allows you to modify the html. Like this:

add_filter ('wp_nav_menu', 'wpse312466_add_loginlink'); 
function wpse312466_add_loginlink ($nav_menu, $args) {
  $nav_menu = '<div id="loglink"><a href="/link/to/loginpage">Login here</a></div>' . $nav_link
  return $nav_menu

Now it depends on your css skills to get that link in the place where you want it to be.

The obvious place to stick this code is in a child theme, but you could also make it into a plugin.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.