• Resolved kosmicbird

    (@kosmicbird)


    I added a “forums” tab and a “blog” tab to my navigation bar. For some reason when I am visiting the forums page, both the “forums” and “blog” menu tabs are highlighted on the navigation menu.

    It should only highlight “forums” when I’m viewing forums and “blog” when I’m viewing the blog… why is it doing this and how do I fix it?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter kosmicbird

    (@kosmicbird)

    I also want to add that when I am visiting deeper links within the “forums” pages, sometimes the “forums” menu item doesn’t even highlight and it only highlights “Blog” even if I am viewing forum pages…

    Theme Author Rigorous Themes

    (@wpgaint)

    Hi @kosmicbird,

    Have you posted same post in both forum and blog?

    Thread Starter kosmicbird

    (@kosmicbird)

    Hello @rigorousthemes

    No, I have not posted the same post. Even when I have the forums completely empty it does this. It only started happening once I made my homepage static (originally the home page was the blog page) and added the blog as a menu item.

    Thread Starter kosmicbird

    (@kosmicbird)

    After further research,

    It looks like the blog section of my site is getting highlighted when I visit any archive. This theme basically treats all archives, whether they are from custom post types or stock ones as children of the Blog. Thus this theme highlights the blog whenever I visit my forums (an archive)

    Thread Starter kosmicbird

    (@kosmicbird)

    Is there any fix for this?

    Theme Author Rigorous Themes

    (@wpgaint)

    Can you change home page from ‘Blog’ to some other pages to test? If you find same issue again feel free to post your problem in detail with screenshot and url of pages which make multiple menu item highlighted.

    Thread Starter kosmicbird

    (@kosmicbird)

    I ended up having to write this script in functions.php as a workaround:

    function custom_fix_blog_tab_on_cpt($classes,$item,$args) {
      if(!is_singular('post') && !is_category() && !is_tag()) {
         $blog_page_id = intval(get_option('page_for_posts'));
         if($item->object_id == $blog_page_id) {
    unset($classes[array_search('current_page_parent',$classes)]);
    }
         }
       }
       return $classes;
    }
    add_filter('nav_menu_css_class','custom_fix_blog_tab_on_cpt',10,3);

    This removes the current_page_parent class from archive pages so that when I have my forums (an archives-type page) active, the blog page isn’t highlighted in the navigation menu.

    Hi there. We have the same problem with the STocky theme for photo downloads.
    If we are in the Shop Photos categories or Downloads pages, it highlights the “blog” tab in the menu bar.

    No idea. Would this script you have found, work for us, or do you think that is dependent on your theme?

    Follow up, I think it is if some of the LINKS are relative, and some are FULL URLs.
    I’ve just manually added our Blog link as /blog, rather than just selecting blog and copying it over, and it work.

    In the source code, some links are full, some are relative. Even on the Download page, the ‘blog’ was full, and showed as a current parent page.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Wrong Navigation Item Highlighted When Page Active’ is closed to new replies.