- This topic has 18 replies, 2 voices, and was last updated 8 years, 6 months ago by Tom.
-
AuthorPosts
-
October 17, 2015 at 11:55 pm #145336Uwe 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:
October 18, 2015 at 10:02 am #145406TomLead DeveloperLead DeveloperHi there,
This should help: https://generatepress.com/forums/topic/menu-item-forum-thinks-it-is-a-child-of-item-blog/#post-141727
October 18, 2015 at 10:18 am #145417Uwe PfeiferI 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
October 18, 2015 at 10:24 am #145422Uwe Pfeiferin the menu settings i have forum blog but it appears as blog forum and still, the wrong item is highlighted when selecting forum
October 18, 2015 at 10:36 am #145425Uwe Pfeiferthe 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;
}?>
October 18, 2015 at 10:51 am #145429Uwe Pfeiferwait 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?
October 18, 2015 at 10:59 am #145431Uwe Pfeiferalso if i click the forum link, in the browser title bar its not Forums | UnityHub but instead just Forums | ?
October 18, 2015 at 11:06 am #145433TomLead DeveloperLead DeveloperI 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.
October 18, 2015 at 11:12 am #145435Uwe Pfeiferi 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?
October 18, 2015 at 11:19 am #145436TomLead DeveloperLead DeveloperJust 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.
October 18, 2015 at 12:32 pm #145446Uwe Pfeiferthank you a lot for the information.
yes i put the new code inside the functions.php but its still not working.
October 18, 2015 at 2:17 pm #145452TomLead DeveloperLead DeveloperHmm, I’ve tested it successfully.
When you go to “Settings > Forums”, what do you have set as your “Forum Root”?
October 18, 2015 at 9:40 pm #145517Uwe PfeiferForum root is “forums”
October 18, 2015 at 11:58 pm #145560TomLead DeveloperLead DeveloperOk, 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).
October 19, 2015 at 3:25 am #145588Uwe Pfeiferno, doesnt work. still the same. when clicking on forum, nothing is highlighted.
-
AuthorPosts
- You must be logged in to reply to this topic.