Auto navigation entry for forums

Hi,
I'm not sure if this is a Forums query or general WPMU query.

I have the forums plugin network activated on my site.
On the primary site the (using default buddypress theme) it automatically has navigation for forums, groups etc. even if no forums or groups exist.

However, in a network site, the navigation only says 'Home','Sample Page', with no links to forums (and no links to groups, but not having network site groups is a whole other issue)

I have added a forum to the network site, navigation does not update.

I am aware that I can go into appearance -> menu and create a custom menu with links to the forums on the network site. However this is not scalable, to ask every site creator to set up their own menus and navigation after registering.

I'm aware that this is not strictly an issue with your plugin, and more likely and issue with the default behaviour of the theme itself.

However, has anyone yet come across this and solved it? (most likely a theme edit, which I am about to look at myself now - if I solve it I'll be back soon.. I just wanted a rant)

  • Philip John

    Hiya!

    On the primary site the (using default buddypress theme) it automatically has navigation for forums, groups etc. even if no forums or groups exist.

    These are added by BuddyPress which provides all those features.

    However, in a network site, the navigation only says 'Home','Sample Page', with no links to forums (and no links to groups, but not having network site groups is a whole other issue)

    That's because the BuddyPress features can only be used on your main site.

    I have added a forum to the network site, navigation does not update.

    The forum plugin that you are using is separate from BuddyPress and will therefore not add to the navigation in any way.

    I am aware that I can go into appearance -> menu and create a custom menu with links to the forums on the network site. However this is not scalable, to ask every site creator to set up their own menus and navigation after registering.

    Most themes include a navigation menu that by default shows pages. The Forums plugin allows you to add a forum to any page or post. Therefore, it should be possible that all sub-site owners need to do is add a page with a forum in and that will appear on the navigation menu. E.g. test it in the default theme.

    Thanks,
    Phil

  • kimedia

    Thanks Phil.

    The way in which I ended up solving my problem was simply to create a function within functions.php that hooked into wp_nav_menu_items. That way if a site owner changes their theme it should still work

    function add_forum_menu_item($items, $menu)
    {
    
       $result = new WP_Query(array(
        'post_type'=>'forum',
        'post_parent'=>0,
        'post_status'=>'publish'
      ));
    
    if($result->have_posts())
    {
     $items .= '<li><a href="'.site_url('forums').'">Forums</a></li>';
    }
    	return $items;
    }
    add_filter( 'wp_nav_menu_items', 'add_forum_menu_item',10, 2 );

    I've done the same for wikis. So now, if a site owner creates a forum or wiki a page is automatically added to their main navigation, rather than forcing navigation through widgets.

    It was far easier than I was thinking

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.