ThemeShaper Forums » Thematic

[closed]

Force current menu item for custom taxonomy pages

(13 posts)
  • Started 2 years ago by ivanoconfa
  • Latest reply from ivanoconfa
  • This topic is resolved
  1. ivanoconfa
    Member

    Hello
    Is it possible to force the thematic menu to highlight a chosen menu item as current menu item? Whenever taxonomy.php pages are viewed the current menu item reverts back to the homepage menu link. I would like to force the current menu item to be a different one, definitely not the homepage menu link.
    Thank you, hope someone can help.

    Posted 2 years ago #
  2. I think I know what you're talking about. Is your home page your blog page? I have the same issue with The Events Calendar.

    Unfortunately I don't have a suggestion but am also having the same problem.

    Can be seen here: http://www.dancespacesantafe.com/

    Posted 2 years ago #
  3. @rob in your case why can't you just use:

    .current-menu-item a { background: pink; }

    as the selector for the active menu on your events page? this is probably something that should make its way into thematic.

    @ivanoconfa i can't say if the same is true for your site because you didn't provide a link

    Posted 2 years ago #
  4. ivanoconfa
    Member

    Thanks Rob and Helga. I am developing a model agency website locally and at present I cannot provide a link. I am familiar with the .current-menu-item selector but my problem is that the menu items of some taxonomy pages are not in the menu. I am trying to make a chosen menu item active even though the actual corresponding page is not viewed.
    To explain further the custom taxonomy pages - models/gender/women for instance - are in fact results pages and I want to make active the menu item which relates to them and is present in the menu, in my case a generic "models". At the moment every time a taxonomy result page is viewed, Wordpress thinks the current menu item is homepage.
    Hope this makes sense, I should be uploading the website to start testing soon. Thanks again.

    Posted 2 years ago #
  5. ivanoconfa
    Member

    I think that there should be some functions if statement such as:
    if is template 'taxonomy.php' then current menu item is 'models'
    and if is template 'model-search.php' then current menu item is 'models'

    (only that I don't know how to write that..)
    Thank you

    Posted 2 years ago #
  6. bogh
    Member

    @ivanoconfa I am pretty sure that what you want can be done trough CSS.

    If your using the other pages as sub-menus you could use something like

    .parent-pageid-42.pageid-47 .current-menu-item a { background: pink; }

    You have lots of specific classes in the thematic's body, so I think this could be pretty simple. But if you want someone to tell you exactly you should show us the website.

    Posted 2 years ago #
  7. yeah i do most dev locally too... it just makes it hard to help. though i think this is a shortcoming in WP... i'm not aware that the menu classes get parent/ancestor classes for taxonomy archives.

    Posted 2 years ago #
  8. ivanoconfa
    Member

    Hi again and thank you for your help so far.
    I have uploaded a test website, still in development and for members only but the menu can be seen at:

    flawlessmodelagency.com

    user name: developers
    password: modelagency2012

    Once in, if you look at this page (single-model.php)
    http://flawlessmodelagency.com/model/sarah-robertson/
    or the taxonomy page (taxonomy.php)
    http://flawlessmodelagency.com/specialty/catwalk/

    the lava lamp menu reverts back to the homepage menu link as if that was the current menu item .

    Thank you.

    Posted 2 years ago #
  9. i'd start with un-doing things to see what/if any thing is causing that. there's no reason that the menu should be saying current_page_item. i'm a little stumped. the menu is generated by wp_nav_menu right?

    Posted 2 years ago #
  10. ivanoconfa
    Member

    yes, standard wp menu. Which should be the current menu item then if the links are not actually on the menu?
    I mean, can I tell WP to select 'models' as the current menu item even if I am viewing those two pages?

    Posted 2 years ago #
  11. bogh
    Member

    I think you could add those pages as submenus of "women/men", and if you don't want to display them in the menu you could hide them trough css. After that they will be part of the "Models" menu, so it will stay active when on those pages.

    Posted 2 years ago #
  12. ivanoconfa
    Member

    Thanks Bogh. That wouldn't work for this type of website, there will potentially be up to 100 model pages using single-model.php.

    Posted 2 years ago #
  13. ivanoconfa
    Member

    I resolved this in the end with a hack found in another forum post, see below:

    // this forces the class current-menu-item to a menu item which I named 'models' (can be any name I presume as long as it is specified in the URL in the code)
    
    add_filter('nav_menu_css_class', 'remove_link_parent_menu_classes', 420 ,3);
    
    function remove_link_parent_menu_classes($classes, $item, $args){
    
    if(strpos($item->url, '/models/') !== true)
    
        return array_diff($classes, array('current_page_item', 'current-menu-item'));
    
      return $classes;
    }
    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.