Cyber Week Sale! Get $20 off GP Premium, $40 off our new Lifetime license, and 45% off license renewals/extensions! Learn more

[Resolved] problems: menu & bbpress

Home Forums Support problems: menu & bbpress

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #145336
    Uwe Pfeifer

    I have a problem. If I click “Forums” (bbpress) in the menu, the highlighted item is “Blog” not “Forums”. Can you help me? Here a video:

    #145406
    Tom
    Lead Developer
    Lead Developer
    #145417
    Uwe Pfeifer

    I added this into functions.php but now the menu item Forum is moved to the right, and its still not working.

    function generate_remove_bbpress_parent_classes($class)
    {
    return ( $class == ‘current_page_parent’ ) ? FALSE : TRUE;
    }

    add_filter(‘nav_menu_css_class’, ‘generate_remove_bbpress_parent_class’);
    function generate_remove_bbpress_parent_class($classes)
    {
    switch (get_post_type())
    {
    case ‘forum’:
    // we’re viewing a custom post type, so remove the ‘current_page_parent’ from all menu items.
    $classes = array_filter($classes, “generate_remove_bbpress_parent_classes”);
    break;
    }
    return $classes;
    }

    the website is here: http://www.unityhub.eu

    #145422
    Uwe Pfeifer

    in the menu settings i have forum blog but it appears as blog forum and still, the wrong item is highlighted when selecting forum

    #145425
    Uwe Pfeifer

    the functions.php looks like this now hope i made the ?> correct at the end:

    <?php
    /**
    * Generate child theme functions and definitions
    *
    * @package Generate
    */

    function generate_remove_bbpress_parent_classes($class)
    {
    return ( $class == ‘current_page_parent’ ) ? FALSE : TRUE;
    }

    add_filter(‘nav_menu_css_class’, ‘generate_remove_bbpress_parent_class’);
    function generate_remove_bbpress_parent_class($classes)
    {
    switch (get_post_type())
    {
    case ‘forum’:
    // we’re viewing a custom post type, so remove the ‘current_page_parent’ from all menu items.
    $classes = array_filter($classes, “generate_remove_bbpress_parent_classes”);
    break;
    }
    return $classes;
    }

    ?>

    #145429
    Uwe Pfeifer

    wait now it’s working – the blog item doesnt get highlighted anymore. but now the forum element isnt highlighted aswell when i click on forum but id like that one to get highlighted?

    #145431
    Uwe Pfeifer

    also if i click the forum link, in the browser title bar its not Forums | UnityHub but instead just Forums | ?

    #145433
    Tom
    Lead Developer
    Lead Developer

    I made a change to the code to add the current menu item class to the blog while on it: https://gist.github.com/generatepress/f5e4f6d1795cf6bb4c6a

    As for the title tag – that’s bbPress/WordPress functionality. Your best bet is using a plugin like WordPress SEO to change the structure of the title tag for the forums post type.

    #145435
    Uwe Pfeifer

    i now put this code in the file, overwriting the old code:

    function generate_remove_bbpress_parent_classes($class)
    {
    return ( $class == ‘current_page_parent’ ) ? FALSE : TRUE;
    }

    add_filter(‘nav_menu_css_class’, ‘generate_remove_bbpress_parent_class’);
    function generate_remove_bbpress_parent_class( $classes, $item )
    {
    switch (get_post_type())
    {
    case ‘forum’:
    // we’re viewing a custom post type, so remove the ‘current_page_parent’ from all menu items.
    $classes = array_filter($classes, “generate_remove_bbpress_parent_classes”);

    if ( $item->url == get_permalink( get_option( ‘page_for_posts’ ) ) ) {
    $classes[] = ‘current_page_parent’;
    }

    break;
    }
    return $classes;
    }

    but still the forum element is not highlighted when activated.

    and about the title … for all other menu items it works – just not for the forum one? why would a seo plugin help me there?

    #145436
    Tom
    Lead Developer
    Lead Developer

    Just updated it again: https://gist.github.com/generatepress/f5e4f6d1795cf6bb4c6a

    The WordPress SEO plugin allows you to set the structure for the title tag for custom post types. Some custom post types, bbPress included, don’t display the title tag very nicely.

    GP doesn’t do anything to the title tag, we leave it 100% up to WordPress and plugins incorporation custom post types. bbPress just isn’t developed to include nice title tags.

    #145446
    Uwe Pfeifer

    thank you a lot for the information.

    yes i put the new code inside the functions.php but its still not working.

    #145452
    Tom
    Lead Developer
    Lead Developer

    Hmm, I’ve tested it successfully.

    When you go to “Settings > Forums”, what do you have set as your “Forum Root”?

    #145517
    Uwe Pfeifer

    Forum root is “forums”

    #145560
    Tom
    Lead Developer
    Lead Developer

    Ok, let’s try this again: https://gist.github.com/generatepress/f5e4f6d1795cf6bb4c6a

    That code should remove the highlight from the Blog menu item, but keep the highlight while on the main forum pages (yoursite.com/forums).

    #145588
    Uwe Pfeifer

    no, doesnt work. still the same. when clicking on forum, nothing is highlighted.

Viewing 15 posts - 1 through 15 (of 19 total)
  • You must be logged in to reply to this topic.