I'm working on a wordpress site where I'm trying to get the "Members" login/logout link & widget area inserted into the actual end of my front-end-nav-menu instead of after, as it's currently positioned. The reason for this is when a user visits the website on a smaller screen the "Members" link and facebook icon (that I've placed in the widget area) stays to the far left under the nav menu instead of staying in line with the nav menu links.

enter image description here

My code on the header.php files is here:

<div class="front-end-nav-menu primary-nav">
                    <?php wp_nav_menu( array('menu' => 'Front End Menu') ); ?>

                    <div id="menu-items">
                        <div id="login-logout-header-button">
                            <?php if ( ! is_user_logged_in() ) { ?>
                                    <a href="<?php echo wp_login_url( wp_guess_url() ); ?>" class="logged-button"><?php _e( 'Members', APP_TD ); ?></a>

                            <?php } else { ?>
                                    <a href="<?php echo wp_logout_url( wp_guess_url() ); ?>" class="logged-button"><?php _e( 'Logout', APP_TD ); ?></a>

                            <?php } ?>
                        </div><!-- /login-logout-header-button -->

                        <div id="facebook-desktop">
                            <?php if ( ! dynamic_sidebar( 'facebook' ) ) : ?>
                            <?php endif; ?>

                    </div><!-- /menu-items -->
                </div><!-- /front-end-nav-menu primary-nav -->

Is there a way to have this #menu-items section in a function an the add the function into the nav bar?

1 Answer 1



function my_nav_menu_primary_navigation($items, $args) { 
  $items .= '<li>Hello :D</li>'; 
  return $items; 

add_filter( "wp_nav_menu_{MENU SLUG}_items", "my_nav_menu_primary_navigation", 10, 2 );

find {MENU SLUG}


The "wp_nav_menu_menu-slug_item" filter runs at the end near the end of wp_nav_menu, $ items is a string containing the HTML extructura the menu and $ args are the arguments that you passed to the function "wp_nav_menu".

The only thing that you have to look out for or seek to use this is what the "{MENU SLUG}" on your menu.

This is a translation of google, do not write in English: D

In Spanish:

El filtro "wp_nav_menu_menu-slug_item" se ejecuta al final casi al final de wp_nav_menu, $items es un string que contiene la extructura de HTML del menu y $args son los argumentos que le pasaste a la funcion "wp_nav_menu".

Lo unico que que tenes que fijarte o buscar para poder usar esto es cual es el "{MENU SLUG}" de tu menu.

  • Hi Salem, similar to your other answer, can you please file an edit here too to explain what your code does. Thank you!
    – Tim Malone
    Jul 6, 2016 at 0:40
  • Thanks for your help on this Salem! I'm afraid I don't quite get what I'm supposed to do? I believe I've gotten the slug of my menu and updated the MENU SLUG part with it and placed the code in the functions.php file and updated it but nothing changed.
    – kia4567
    Jul 6, 2016 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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