[resolved] Dynamic Menu Highlighting with subcategories (2 posts)

  1. disembodied
    Posted 9 years ago #

    Hello, on my website I have tabs via CSS that list my main categories and static pages. I have it set up to highlight whatever category (or if the post is in the category) you are currently on.
    However, one issue I am having is lets say a user selects one of my subcategories... my tabbed menu doesn't have an option for that, so if you are on that subcategory's page no tab is highlighted. I would like to have the parent category's tab highlighted.
    Now I know I can do this with multiple if statements the same way I did the rest, or I could use a switch command. But before I did either of those, I wanted to know if there was just some special wordpress code I could use to gather up the parent category and all its subcategories in one easy code.


  2. disembodied
    Posted 9 years ago #

    Well I found a way to do this on another post:


    using the is_child plugin to then use an is_child function is the cleanest, easiest way to do this it seems. And get has the added benefit of working for single pages without using the single page function.


Topic Closed

This topic has been closed to new replies.

About this Topic