php - How do I add login/logout links to navigation in specific position -


i'm trying add login/logout links main navigation menu , did follow:

add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2); function add_login_logout_link($items, $args) {         ob_start();         wp_loginout('index.php');         $loginoutlink = ob_get_contents();         ob_end_clean();         $items .= '<li>'. $loginoutlink .'</li>';     return $items; } 

that works add links end , need add in 2nd position example, how that?

add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2); function add_login_logout_link($items, $args) {     ob_start();     wp_loginout('index.php');     $loginoutlink = ob_get_contents();     ob_end_clean();     $mylink.= '<li>'. $loginoutlink .'</li>';     array_splice( $items, 1, 0, $mylink);  return $items; } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -