Skip to content

Instantly share code, notes, and snippets.

@jimboobrien
Forked from wpscholar/append-nav-items.php
Created September 20, 2017 23:30
Show Gist options
  • Save jimboobrien/88e237f137783b6e03ec0fc9931e75c6 to your computer and use it in GitHub Desktop.
Save jimboobrien/88e237f137783b6e03ec0fc9931e75c6 to your computer and use it in GitHub Desktop.
Add a custom link to the end of a menu that uses the wp_nav_menu() function
<?php
/**
* 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 .= '<li><a title="Admin" href="'. esc_url( admin_url() ) .'">' . __( 'Admin' ) . '</a></li>';
}
return $items;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment