Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to edit the Buddypress default theme navigation?


  • 5227699
    Inactive

    I’m trying to figure out how to edit the default theme, but I’m stuck on where and how to edit the look of the navigation…the horizontal menu bar? Can someone point me to a tutorial on how to edit this?

Viewing 25 replies - 1 through 25 (of 36 total)

  • @mercime
    Keymaster

    @mercime

    WP/BP versions? What theme are you using – bp-default child theme or WP theme with BP Template Pack? What exactly do you want to do with the menu?


    5227699
    Inactive

    sorry…WP 3.2.1, BP 1.2.9
    bp-default child theme
    I want to be able to choose what shows in the menu and currently I have no idea how to do this…I also would like to edit the look of it, change to an image maybe? Not sure yet…but right now I have no clue how to even start being able to tweak that menu bar.


    @mercime
    Keymaster

    @mercime

    One way to change the menu links would be to hardcode the links you want there. This would mean copying the header.php file from bp-default theme into your child theme folder.

    Another way is to set up a new custom menu which would involve creating a functions.php in your child theme and copying over the header.php from bp-default theme into your child theme folder. The following should help you get wp_nav_menu going in your theme http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus

    sorry to barge in here, i cant start a new topic hense this post

    does anyone know how i can hide my sites menu (activity, members, groups, forum) navbar from un-registered / logged-out members..?

    thanks in advance

    using bp 1.5 default with child theme, wp 3.2.1

    okay so I’ve done some digging and found – nav-menu.php
    copied it to my child themes folder and created two seperate menus in my admin dashboard.

    I found this code for the menu config: here: https://codex.wordpress.org/Function_Reference/wp_nav_menu


    `<?php
    if ( is_user_logged_in() ) {
    wp_nav_menu( array( ‘theme_location’ => ‘logged-in-menu’ ) );
    } else {
    wp_nav_menu( array( ‘theme_location’ => ‘logged-out-menu’ ) );
    }
    ?>`



    Am I getting warm..?

    If so, just two questions remain..

    a) where in: nav-menu.php do I add the above code..?

    b) Does the above code need to be wrapped at all..?

    Kind regards in advance :)


    aces
    Participant

    @aces

    How about the following (in the header?) instead of what’s there (bp 1.5.1)
    `// https://codex.wordpress.org/Function_Reference/wp_get_current_user
    $current_user = wp_get_current_user();
    if ( 0 == $current_user->ID ) {
    wp_nav_menu( array( ‘container’ => false, ‘menu_id’ => ‘nav’, ‘theme_location’ => ‘secondary-menu’, ‘fallback_cb’ => ” ) );
    // Not logged in.
    } else {
    wp_nav_menu( array( ‘container’ => false, ‘menu_id’ => ‘nav’, ‘theme_location’ => ‘primary’, ‘fallback_cb’ => ” ) );
    // Logged in.
    }
    `
    ? (wrapped in “ tags)

    hi @aces !

    thanks for the alternative option

    does your post imply that the example I’m trying to use will NOT work then.?

    by the way I have 3 menus in place:

    primary navigation – logged-in-menu

    mobile menu – mobile (buddypress mobile)

    logged-out-menu


    aces
    Participant

    @aces

    Actually I think it should, but I didn’t try it as I was already experimenting with the above for a non bp site and tried it out on a bp test site and it worked.

    I quite like this approach because you could also use the data (see link) to do other things as well…..

    ok gonna give it a try (fingers crossed)

    I’ll pop it in my child themes header.php (bp default 1.5.1)

    any particular nesting point..?


    aces
    Participant

    @aces

    I’m using a customised bp-columns, which is mostly the same as bp-default.

    I would just replace
    `wp_nav_menu( array( ‘container’ => false, ‘menu_id’ => ‘nav’, ‘theme_location’ => ‘primary’, ‘fallback_cb’ => ‘bp_dtheme_main_nav’ ) );`
    which begins and ends with php tags with the above also wrapped in php tags….

    the mobile angle is something else…

    customized bp-columns? sounds interesting !

    does the fact that I have the secondary navigation as the mobile version of the site make any difference? just got this gut feeling that this may just fail unless I call the secondary the logged-out-menu as my theme at present only supports 2 menus.


    aces
    Participant

    @aces

    It would help if you had a test site to try it out on, ie: localhost or a subdomain…

    good point !
    can’t afford any more site breaks on a flourishing community

    I take it my initial plan A is not worth pursuing then?

    It does address both menus specifically speaking..

    just realized I’ll have to make up a third theme location to pull this one off :( when does the editing ever end lol


    aces
    Participant

    @aces

    I’ve just tried the following on a bp test site instead of the single menu and it worked
    `
    <?php
    if ( is_user_logged_in() ) {
    wp_nav_menu( array( ‘container’ => false, ‘menu_id’ => ‘nav’, ‘theme_location’ => ‘primary’, ‘fallback_cb’ => ” ) );
    } else {
    wp_nav_menu( array( ‘container’ => false, ‘menu_id’ => ‘nav’, ‘theme_location’ => ‘secondary-menu’, ‘fallback_cb’ => ” ) );
    }
    ?>
    `

    nb: The test site is also using the walled garden technique…

    single menu..?

    I really think I gotta create the third theme location first, because the fall-back call will end up showing logged-out visitors my mobile menu which is a duplicate of the primary location so in theory my menu tabs will still be on display

    @aces just had a thought! instead of calling up the ‘secondary-menu’ would it be possible to void out / null the request to fallback on no menu at all..?

    i.e. – => false, ‘menu_id’ => ‘nav’, ‘theme_location’ => ‘no-menu’, ‘fallback_cb’ => ” ) );

    or – => false, ‘menu_id’ => ‘nav’, ‘theme_location’ => ‘//’, ‘fallback_cb’ => ” ) );


    aces
    Participant

    @aces

    I’m not sure what you mean – but according to https://codex.wordpress.org/Function_Reference/wp_nav_menu you could have ` ‘fallback_cb’ => false,`

    I don’t know how you are doing the mobile menu, but couldn’t you just have $current_user logged in and out mobile menus?

    If someone can guess the page such as activity, then just hiding the menu won’t stop them getting in anyway.

    the mobile menu is just for the mobile version of the site via the buddypress mobile plugin
    I don’t want the mobile menu being ‘hidden’ from logged-out mobile users really, mainly desktop users.

    I’ve put some mods in the activity-loop etc for keeping activity updates, profiles and members, groups, and forum directories ‘garden-walled’ as such so may have that angle covered?

    so to clarify: in my header.php (child theme) replace..

    wp_nav_menu( array( ‘container’ => false, ‘menu_id’ => ‘nav’, ‘theme_location’ => ‘primary’, ‘fallback_cb’ => ‘bp_dtheme_main_nav’ ) );

    with:

    <?php
    if ( is_user_logged_in() ) {
    wp_nav_menu( array( ‘container’ => false, ‘menu_id’ => ‘nav’, ‘theme_location’ => ‘primary’, ‘fallback_cb’ => ” ) );
    } else {
    wp_nav_menu( array( ‘container’ => false, ‘menu_id’ => ‘nav’, ‘theme_location’ => ‘secondary-menu’, ‘fallback_cb’ => false,
    }
    ?>

    I’ve just checked my header.php and it appears to be worded slightly differently actually..? for example:

    false, ‘menu_id’ => ‘nav’, ‘theme_location’ => ‘primary’, ‘fallback_cb’ => ‘bp_dtheme_main_nav’ ) ); ?>


    aces
    Participant

    @aces

    in the bp-default header ( should be line 46 – 48 )
    `

    `
    replace it in your child theme with something like
    `

    `
    as it is the last parameter, I don’t think false has a comma after it in this context….

    Make sure you back up before any edits in case something goes wrong!

    nb: to use code on buddypress.org put backticks ` (normally above tab key) before and after…

    many thanks @aces !!
    respect man :)

    I haven’t tried it yet as I wanted to see if there was an alternative way of backing up just the file/s I am working on, in the past, I’ve encountered site breaks during custom, and have developed a bad habit of doing full cpanel backups following these breaks. This has led to me losing several new member registrations on my site.

    Is there an alternative method I can adopt – i.e. doing a copy of file first and saving it to a backup folder for instance, so that if something goes wrong I can just replace the file instead of restoring the whole public_html directory?

    excuse my lack of back-ticks, it’s been a while..I’m a bit rusty lol


    aces
    Participant

    @aces

    something like filezilla ?

    Thanks for that!

    I just deleted the bp-mobile plugin due to technical problems and I’m back with just a single menu now..? (primary) seems like bp-mobile creates a secondary theme location. I guess I could just use the plugin to create the secondary location / menu and choose my custom logged-out menu from the drop down right?

Viewing 25 replies - 1 through 25 (of 36 total)
  • The topic ‘How to edit the Buddypress default theme navigation?’ is closed to new replies.
Skip to toolbar