This website uses cookies to allow us to see how the site is used. If you continue to use this site, we assume that you are okay with this. If you want to use the sites without cookies, please see our privacy policy.

Append Items to a Nav Menu

One of the things that is common when working with WordPress clients is they have a tendency to forget their login URL.  Appending an ‘Admin’ link to the end of the footer that the user can’t remove is one way to ensure your client can always find the admin without having to give you a call.

* Add a custom link to the end of a specific menu that uses the wp_nav_menu() function
add_filter('wp_nav_menu_items', 'add_admin_link', 10, 2);
function add_admin_link($items, $args){
    if( $args->theme_location == 'footer_menu' ){
        $items = $items . '<li><a title="Admin" href="'. admin_url() .'">' . __( 'Admin' ) . '</a></li>';
    return $items;

With a few alterations, you can append ( or prepend ) anything to a nav menu.  A few examples would be search fields, dynamically generated ‘Log In’ and ‘Log Out’ links, ‘User Profile’ or ‘User Account’ links, fancy images or icon fonts, and the list goes on…


A professional WordPress developer for over a decade, Micah has worked on sites for Fortune 100 companies, has released over a dozen WordPress plugins, is a frequent speaker at WordCamps, co-organizes the WordPress Gwinnett meetup, is a co-host on the WP Square One podcast and shares his knowledge by blogging on WordPress development topics. Currently, Micah works at Bluehost as a WordPress contributor.

4 thoughts on “Append Items to a Nav Menu

  1. This is a little silly, as it is just as easy to hard code in a link to wp-admin, or whatever. Still, there is something ‘techie’ feeling about using the themes functions file. I might add this snippit to my Flashy Functionality plugin or the Free Theme I’m working on now?!

    1. It’s always good practice to avoid hard coding links as they can cause major update problems down the line.
      It doesn’t take much extra work to use dynamic code, trust me, your client and your future self will be thankful of it!

  2. Not really, if you take functionality out of the scope of look and feel this would quite plausibly be applied in a settings plugin, if the theme is ever changed the functionality still remains, if you hard code into the theme you lose it if the theme is changed! ><

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.