WordPress.org

Ready to get started?Download WordPress

Forums

Check for parent category in sidebar (3 posts)

  1. Prometheus
    Member
    Posted 9 years ago #

    I have a menulist with link to a category Articles on my website (and some other links to categories).

    When entering Articles from the menulist, the link get black to indicate where you are. Also, a list of subcategories appear in the sidebar (subjects like webdesign, php etc). I have accomplished this with
    is_category('Articles')

    Now to the problem - when you click a subcategory for 'Articles' - like 'Webdesign' - the is_category('Articles') is not true any more, and the list of subcategories in the sidebar disapear and the Articles-link in the menulink become blue again.

    How do I check that the visitor is still in the Articles-category when they navigate down to subcategories? Is it possible in any other way then making a lot of conditions like

    if (is_category('Articles') || is_category('Webbdesig') (and so on)

    Thanks for any help. Hope I have translated everything correct, I'm from sweden so english is not my language ;)

    / Mattias

  2. moshu
    Member
    Posted 9 years ago #

    I am afraid that is the only way: using a lot of conditionals (if statements).

  3. Prometheus
    Member
    Posted 9 years ago #

    Ok, thanks moshu :)

    Its not that many subcategories so I guess it could work anyway. But it would been nice with an easier solution. Maybe a task for a new plugin - perhaps I will try to create one some day :)

Topic Closed

This topic has been closed to new replies.

About this Topic