English flagItalian flagKorean flagChinese (Simplified) flagChinese (Traditional) flagPortuguese flagGerman flagFrench flagSpanish flagJapanese flagArabic flagRussian flagGreek flagDutch flagBulgarian flagCzech flagCroatian flagDanish flagFinnish flagHindi flagPolish flagRomanian flagSwedish flagNorwegian flagCatalan flagFilipino flagHebrew flagIndonesian flagLatvian flagLithuanian flagSerbian flagSlovak flagSlovenian flagUkrainian flagVietnamese flagAlbanian flagEstonian flagGalician flagMaltese flagThai flagTurkish flagHungarian flagBelarus flagIrish flagIcelandic flagMacedonian flagMalay flagPersian flag

Add All Pages To Buddypress Admin Bar Dynamically


Want to add all your pages into your buddypress admin bar automatically?

It’s easy as pie! Just add wp_list_pages to your buddypress bar with the following code!

Create a file called erocks-admin-bar-mod.php in your /plugins/ dir, put in the following code, then activate the BP Nav Bar Mods Plugin on the plugin control panel

{code type=php}
<?php
/*
Plugin Name: BP Nav Bar Mods – Add All Pages
Plugin URI: http://erikshosting.com
Description: Add All Your Pages To The Buddypress Admin Bar Automatically!
Author: Erock
Version: 1.0
Author URI: http://erikshosting.com
*/

//Links and Menus Added To The Following Function Are Always Visible On The BP Bar
function bp_adminbar_currentsite_menu() {
global $bp;
?>

<!– Call All Pages Via A WordPress Shortcode! –>
<?php wp_list_pages(‘title_li=’); ?>

<?php
}

// Call The Function Above
add_action(‘bp_adminbar_menus’, ‘bp_adminbar_currentsite_menu’, 999);

?>
{/code}

Or How About As A Drop Down Menu?

{code type=php}
<?php
/*
Plugin Name: BP Nav Bar Mods – Add All Pages
Plugin URI: http://erikshosting.com
Description: Add All Your Pages To The Buddypress Admin Bar Automatically!
Author: Erock
Version: 1.0
Author URI: http://erikshosting.com
*/

//Links and Menus Added To The Following Function Are Always Visible On The BP Bar
function bp_adminbar_currentsite_menu() {
global $bp;
?>

<!– Call All Pages Via A WordPress Shortcode As A Drop Down! –>
<li><a href=”#”>Pages</a>
<ul>
<?php wp_list_pages(‘title_li=’); ?>
</ul>
</li>

<?php
}

// Call The Function Above
add_action(‘bp_adminbar_menus’, ‘bp_adminbar_currentsite_menu’, 999);

?>
{/code}



4 Comments

  1. Thanks I bookmarked this page and will try it out soon. Is this a dropdown menu? As you can see in my website, I want to rewrite the menu items “pages and categories” in a more dynamic way.

    1. No, it wasn’t, but I just added another snippet to the article with the code to show it as a drop down. Its just underneath the first.

  2. Eric,

    Great tutorial – how would we make the new menu only visible to logged-in users?

    Thanks!

    1. put the menu items you want to be logged-in user only visible, inside a logged in check.
      Use this http://codex.wordpress.org/Function_Reference/is_user_logged_in