Editing Navigation
-
Hi,
I’ve been searching through posts on here and through Google for days but can’t find a clear answer to this questsion.
I want to edit the links in the navigation, userbar and optionbar menu, to add new ones and remove ones that I don’t want to use.
I can’t seem to find the code that renders all of these, are they in a file I can edit?
Thanks, James.
-
This is being handled with functions like these:
bp_core_new_nav_itembp_core_new_subnav_itembp_core_remove_nav_itembp_core_remove_subnav_itemAll of these functions (and a lot more) can be found in buddypress/bp-core.php. They are well documented and you can always have a look at the various core component how they use these functions.
To the admin bar you can add links like so:
function sv_add_link()
{
global $bp;
$link = '<li><a href="'. $bp->loggedin_user->domain . 'my-page" title="'. __( 'My Page') .'">'. __( 'My Page') .'</a></li>';
echo $link;
}
}
add_action( 'bp_adminbar_menus', 'sv_add_link' );Removing links also works with actions. Using the example from above you’d have to put this into your functions.php file:
remove_action( 'bp_adminbar_menus', 'sv_add_link' )You have to remove an action at the same priority as it has been added, so if you find an add_action call like this:
add_action( 'bp_adminbar_menus', 'sv_add_link' , 7 );you’d have to remove it with this:
remove_action( 'bp_adminbar_menus', 'sv_add_link' , 7 );Otherwise it won’t work.
Hope this helps you along a bit.
Hi, this is exactly what I have been looking for! Thanks very much!
- The topic ‘Editing Navigation’ is closed to new replies.