In this post,I will show you the quickest way to add menu items to a buddypress site,sitewide.
As you may be knowing,buddypress-wpmu powered sites need at least two themes,one for the site home page and one for the members profile,group etc(called member theme usually).So,when you want to add more menu items to the top navigation, you have two options.
1.Add the menu links to each of the theme(yes, you will have to add the link in the home theme and the buddypress member theme separately).
2.Simply write a small snippet of code and upload it to mu-plugins directory.It will add the link globally.
Well,let us start with the basics,I will take an example of the buddypress default home theme and buddypress default member theme.
Here is what you get as the top nav,when you install buddypress and activate the default themes

Well,so suppose now you want to add a few links(menu items) in the top navigation.As I mentioned, you have two options.
Option 1:-Go and edit the nav (for default theme,It is in header.php, look into your theme for the location of the menu) in the Buddypress Home theme and buddypress member theme.You are done.But suppose, you have to add/remove some links later ,you will have to again edit both the theme.
Well ,I have a shortcut for you.
Option 2:
Buddypress default theme(or any of the well coded buddypress theme) , provides an action hook “bp_nav_items” ,we can use this action hook to hook our new links into the menu.
Well,again we have two choices now.We can either use the functions.php of each of the theme(Home and member and add our function to add links),but again,this causes redundancy.
So,the better option is , let us define the functions in a new file say my-extra-links.php(you may name it what ever you like) and define the action function there as
<?php //add the action hook add_action("bp_nav_items","extra_nav_links"); //insert the links now function extra_nav_links() { ?> <li><a href="#">My Link 1</a><li> <li><a href="#">My Link 2</a></li> <?php } ?>
Relace the hash(#) with the url of your link,and you are done.ahh ,yes, we have yet to upload the file somewhere.Since,In wordpress Mu,the files(or let us say properly ,the plugins) kept in the wp-content/mu-plugins directory gets automatically activated sitewide,we will use this functionality and upload our file to the mu-plugins directory.
Once, you are done with the uploading of the file to the mu-plugins directory, refresh your site page in the browser ,and you will see something like this

Why you should use this approach:-It will allow you to keep your extra menu items ,even if the themes for buddypress gets changed(the only requirement is the new themes should also be using the action hook “bp_nav_items“).Well,I think, this approach, may reduces a couple of minutes in your development time.
So,what do you think? which approach is better? looking forward to your thoughts on it.
We will keep coming with more informative tips,tricks,tutorials to keep you updated with wordpress/buddypress/wordpress mu regularly.If you want to help us,You can ,by spreading the words.We provide free and premium plugins/support for wordpress Mu,buddypress at a very low cost (starting with $30 for 3 months membership).If you or anyone you know,needs some real good plugins/themes for their wordpress Mu/buddypress powered site, Please refer them to http://BuddyDev.com.We will highly appreciate your support and keep coming with more useful and free stuffs.
Related posts:
- Tweaking the registration link at wpmu login page to point to buddypress registration page well,It is not that hard.If you are using buddypress and...
- Changing Buddypress default logo with a custom logo in buddypress admin bar Do you use buddypress? If you use buddypress, you might...
- Showing Sitewide recent posts and Tagcloud on a wordpress Mu site A few days ago,I was working on one of my...
- Allow Users to select blog theme while they signup for a blog or create a new blog on your wordpress mu/buddypress powered site How about allowing your users to select a blog theme...
- Turn Your buddypress website to orkut style Site Now:Grab Cosmic buddy Theme for buddypress We have just released the Cosmic buddy Theme for buddypress....
Related posts brought to you by Yet Another Related Posts Plugin.

![[blinklist]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/blinklist.png)
![[Bloglines]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/bloglines.png)
![[del.icio.us]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/digg.png)
![[dzone]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/dzone.png)
![[Facebook]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/facebook.png)
![[Ma.gnolia]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/magnolia.png)
![[Mister Wong]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/misterwong.png)
![[Reddit]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/reddit.png)
![[Sphere]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/sphere.png)
![[Sphinn]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/sphinn.png)
![[StumbleUpon]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/stumbleupon.png)
![[Technorati]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/technorati.png)
![[Email]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/email.png)



[...] sitewide menuitems to BuddyPress [...]
Thanks for the info. Zip Bam Boom. Worked like a charm. Thanks again.
Thanks. Saw your post and five minutes later have added a couple of useful links to my navigation bar.
Hi Joss
Thanks for the comment.I am glad it helped you
Thank you so much for the info!
Now do you know a way to add slimbox effect sitewide on buddypress?
Thanks for the comments Diego.
it took me sometime,but I hacked slimbox to work globally.
Please check it here
http://bit.ly/13OZuT
Thanks
Brajesh
Hi Thanks!
But I get this errors:
Warning: Unexpected character in input: ‘\’ (ASCII=92) state=1 in /hp/an/ac/cm/www/my/wp-content/mu-plugins/sdfsdfsdf.php on line 14
Warning: Unexpected character in input: ‘\’ (ASCII=92) state=1 in /hp/an/ac/cm/www/my/wp-content/mu-plugins/sdfsdfsdf.php on line 14
Parse error: syntax error, unexpected T_STRING in /hp/an/ac/cm/www/my/wp-content/mu-plugins/sdfsdfsdf.php on line 14
Please help me! Thanks!
I am using the default theme as a blog theme also. Will this also affect the blog theme automatically?
hi Kunal
It will not affect the normal blog theme(I mean the blog theme for users),but it will affect the Home theme(main site theme) and the member Theme.
Thanks
Brajesh
Brajesh,
Thanks for the quick response. Ill give this a try. Btw, we are using BP to power an indian startup community. Would love to get your feedback.
Hey Kunal,Sorry I could not reply earlier.checked the site thoroughly today.It looks very promising.The only thing,I will suggest to improve is the theme,as it looks typically like buddypress theme, A better option will be give it a look and feel of your purpose.As far as other features are concerned,they are very nice.Thumb Up! to you and your team for such a wonderful site
regards
Brajesh
Hey Brajesh,
Thanks for checking out my site and for your encouragement. Theme customizations are progressing slowly. I am an amateur web developer and am still learning how to modify the theme and other components from generous experts like you, one mod at a time
How could I use the same process to remove links? For instance, if I want to remove the default links on my page, how can I do so without modifying the original header.php files?
Thanks
Hi Andres
The default links are hand coded into your header.php of the home theme/buddypress member theme,so there is no way currently to modify them without editing the header file of your themes.
Thanks for dropping by and let me know,if you have any other issues.
thanks
Brajesh
Sweet! That was quite possibly the quickest and easiest fix to my WordPress sites I’ve done in a looooong time. Rock on! Thanks a bunch.
you are most welcome.Thanks for visiting my blog
.I am glad it helped.
Hi,your example really has helped me big-time.However,is there a way the menu items can have a “Highlight selected menu” feature just like the original buddypress menus?
Thanks.
hi Jeremiah
Thanks for the comment.
well,yes, you can have a highlighted menu.It is simple manupulation inside the extra nav adding function.
you can use conditionals to highlight currently selected item.Say you have added about page there,so instead of the code in example you can use something of this kind.Let us do in same way as buddypres default nav uses highlight.
I am sorry,the code is not getting posted in comments,I will be adding it to post in a few minutes.
Hope it helps.
Thanks
Brajesh
I have created a lot of new links and reshuffled the default links. I am also using the suckerfish drop down nav menu. Instead of using bp_nav_items, is there a way to create a completely new function with all my links formatted the way I want it and then hardcore that function into the themes that need to use it?
At least this way, I will need to change code only in 1 location when I need to add/edit links across all the themes.
Thanks for any tips you can provide.
hi Kunal
Thanks for the message.Yes, you can .Put the code for navigation in function(put this function inside your functions.php file) and then call it in your theme.It will work seamlessly.let me know ,how it goes with you.
cheers!
Brajesh
Hey
just seen ur post and added links to my installation but am getting headers already sent error..what could be the problem?
Jerry
hi Jerry
Thanks for the comment.Well the header already send issue is because the file in which you defined extra navigation items has some white spaces(most probably) either before the php begining tag or after the php closing tag.Please remove any space before/ after php block and the issue should go away.let me know how it went with you.
Thanks
Brajesh
Hey
I have tried clearing the white spaces but the error still persists…
Thanks
Jerry
hi,well,so there may be other problem.
Please paste your code on pastebin here http://cosmiccoders.pastebin.com/
and put a link in comments ,I will correct the issue quickly and let you know the problems.
Thanks
Brajesh
Hey
it finally worked.i think the entire problem was in white spaces.
Thanks
Jerry
Great info. How would you get the links to change color once they’ve been selected? Do you have to call the css some how?
My site is
http://www.cinematicknights.com
Thanks for your help!
hi
well, you can use conditionals for the purpose.For example,say on your site you want to highlight events page.
here I have created the code for that one link,Please check it.You can do the similar thing for others.
http://cosmiccoders.pastebin.com/f491531c1
Thanks
Brajesh
Thanks for your help, but I wasn’t able to get it to work. I’m a noob at php and I tried replace the original line of code with the new one you gave me but that didn’t work. I also wasn’t sure how exactly to insert my wp url into the space that you provided. Am I supposed to leave bloginfo? Am I suppposed to leave the parenthesis? In either case when I removed them or left them in, it didn’t work. Can you give me another clue to put me in the right direction? Thank you.
hi Giordany
Please do one thing.Post your original code(how you added the extra menu on your site) here on pastebin http://cosmiccoders.pastebin.com
Drop me a line here,I will check and update the code according to your existing code.So you don’t have to worry about PHP.
Thanks
Brajesh
Awesome, thanks, here it is.
http://cosmiccoders.pastebin.com/m7625d70
Hi again,thanks for the solution you provided last time.It worked wonderfully.I had another issue though,Is it possible to have the members in buddypress arranged in an alphabetical order.I’ve tried using custom functions to do that but it doesn’t work so well because of the database structure buddypress uses.Is there a function in buddpress that supports this maybe in it’s parameters?
Thanks in advance.
I somehow seem to have answered myself.Tried some t wicks here and there and Walla!
Great forum though.