Want more features on Pastebin? Sign Up, it's FREE!
Guest

Add dynamic menu to specific custom menu

By: a guest on Dec 29th, 2012  |  syntax: None  |  size: 0.54 KB  |  views: 35  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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);
clone this paste RAW Paste Data