Trouble with a php code that adds a log in/log out button [closed]

I’m not sure why the space is a bad idea.

Here is the code you would need with a space for the login:

$items .= '<li><a href="' . get_permalink( woocommerce_get_page_id( 'myaccount' ) ) . '">Log In </a></li>';

seems a simple solution.

IF you want to try css, it’s relatively simple as well.

change the same line to this instead:

$items .= '<li><a class="custom-nav-link" href="' . get_permalink( woocommerce_get_page_id( 'myaccount' ) ) . '">Log In</a></li>';

then in your css add this line:

.custom-nav-link {
  margin-right: 15px;
}

Obviously you could change the 15 to any value you want. Repeat for the logout. But you don’t need to add the css again.