I have a custom function for my nav walker menu that adds custom php/html to it, which can be seen below. It renders a twitter bootstrap dropdown menu that I would like to put my login form in.
function add_login_logout_link($items, $args) {
if ( is_user_logged_in() ) {
$items .= '</ul><ul class="pull-right nav"><li><a href="' . wp_logout_url( home_url() ) .'" title="Logout">' . __('Log out', NOVALANG) . '</a></li>';
} else {
$items .= '</ul><ul class="pull-right nav"><li><a href="' . home_url() .'" title="Login">Skapa konto</a></li>
<li class="divider-vertical"></li>
<li class="dropdown">
<a class="dropdown-toggle" href="#" data-toggle="dropdown">' . __('Log in', NOVALANG) . '<strong class="caret"></strong></a>
<div class="dropdown-menu" id="login-dropdown-box" style="padding: 15px;">
<div id="test">' . get_template_part('login') . '</div>
<div style="width: 100%; text-align: center; clear: both; padding: 5px; padding-top: 15px; border-top: 1px solid #888;"><a id="login-dropdown-password" href="' . __(wp_lostpassword_url( $redirect )) .'">Jag har glömt lösenordet</a></div>
</div>
</li>';
}
return $items;
}
add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 4);
The problem here is the rendering of the custom login form using get_template_part(‘login’), which shows up in the top of the page where it really should not be as far as I can see.
<div id="test"></div>
It’s empty! And the login form shows up in the header. I have that code in a separate php-file, but I don’t think that is the problem because I have tried rendering it using other code in a custom function in the functions.php-file.
Anyone who can point me in the right direction?