Skip to content

Instantly share code, notes, and snippets.

@BhargavBhandari90
Last active February 3, 2020 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save BhargavBhandari90/2aaebea7e67e07a08a5baddfcb868583 to your computer and use it in GitHub Desktop.
Save BhargavBhandari90/2aaebea7e67e07a08a5baddfcb868583 to your computer and use it in GitHub Desktop.
Add links to BuddyPress navigation.
<?php
/**
* Add this function to theme's functions.php
*
* Add links to BuddyPress navigation.
* This will add photo, video and music link to BuddyPress navigation.
*
* If you don't want to display "Media" tab, then add following css to
* rtMedia->Settings->Custom CSS:
*
* #media-personal-li {
* display: none;
* }
*
*/
function rtmedia_custom_media_nav_tab() {
if ( ! function_exists( 'bp_core_new_nav_item' ) ) {
return;
}
// Array of links.
$links = array(
'photo' => esc_html__( 'Photos', 'rtmedia' ),
'video' => esc_html__( 'Videos', 'rtmedia' ),
'music' => esc_html__( 'Music', 'rtmedia' ),
);
$c=100;
foreach ( $links as $slug => $menu_title ) {
// Add links to BP navigation
bp_core_new_nav_item( array(
'name' => $menu_title,
'slug' => RTMEDIA_MEDIA_SLUG . '/' . $slug,
'position' => $c,
) );
$c++;
}
}
if ( class_exists( 'BuddyPress' ) ) {
add_action( 'bp_init', 'rtmedia_custom_media_nav_tab', 11, 1 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment