X

Add Custom Navigation in BuddyPress

This snippet will add a new tab and load whatever content you place within wps_sample_action_content() function. You could potentially have anything within this function including a custom loop to show members, activity or really anything you can think of. You can adjust the slug, the text displayed within the tab, tab position, and so on. Just add this snippet to bp-custom.php or functions.php to make your changes and you're all set.


Code Snippet:


add_action( 'bp_setup_nav', 'wps_sample_action', 50 );

function wps_sample_action() {
global $bp;
bp_core_new_nav_item(
array(
'name' => __( 'Sample Page', 'buddypress' ),
'slug' => 'sample',
'position' => 50,
'screen_function' => 'wps_sample_action_template',
'default_subnav_slug' => 'sample',
'parent_url' => $bp->loggedin_user->domain . $bp->slug . '/',
'parent_slug' => $bp->slug
) );
}

function wps_sample_action_template() {
add_action( 'bp_template_title', 'wps_sample_action_title' );
add_action( 'bp_template_content', 'wps_sample_action_content' );
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
}

function wps_sample_action_title() {
echo 'Sample page title';
}

function wps_sample_action_content() {
echo 'Sample page content';
}

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!