SHARE
TWEET

Add dynamic menu to specific custom menu

a guest Dec 29th, 2012 41 Never
  1. // Filter wp_nav_menu() to add profile link to a specific wp_nav_menu
  2. // For example: 'theme_location' =>'mamamia'
  3. // Replace mamamia with your menu's theme_location
  4.  
  5. function mme_nav_menu_profile_link($menu, $args) {
  6.         $profilelink = '<li><a href="' . bp_loggedin_user_domain( '/' ) . '">' . __('My Profile', 'buddypress' ) . '</a></li>';
  7.         if (is_user_logged_in() && ‘mamamia’ == $args->theme_location )
  8.                 return $profilelink . $menu;
  9.         else
  10.                 return $menu;
  11. }
  12. add_filter( ‘wp_nav_menu_items’, ‘mme_nav_menu_profile_link’, 10, 2);
RAW Paste Data
Top