Skip to content

Instantly share code, notes, and snippets.

@wpscholar
Last active March 5, 2024 04:26
Show Gist options
  • Save wpscholar/1249995 to your computer and use it in GitHub Desktop.
Save wpscholar/1249995 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;
}
@umairrazzaq
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment