Append Item to Nav Menu

Programmatically add an item to any menu that is called with wp_nav_menu.

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="'. esc_url( admin_url() ) .'">' . __( 'Admin' ) . '</a></li>';

    }

    return $items;

}

Thanks, Micah Wood! https://gist.github.com/wpscholar/1249995

Comments are closed.

Skip to toolbar