WordPress.org

Support

Support » How-To and Troubleshooting » add class “current” to navigation list item if a child page is selected?

add class “current” to navigation list item if a child page is selected?

  • Hi,
    I’m using wordpress with the superfish jquery dropdown navigation. I a code to check the page or category ID and if the menu list item is in that actegory it gets the class “current”. But now I havce the problem if subpages or subcategories are selected the main navigation point is not “current” anylonger. But I think it would be usefull for orientation. I allready searched the codex page but I can’t get it working. How do I add that the li element get’s th class current if a child page of it is selected as well?

    here’s my code for now:

    <li <?php if (is_category('4')) { echo " class=\"current\"";}?>>

    same with page link like that:

    <li<?php if (is_page('96')) { echo " class=\"current\"";}?>>

    I allready tried something like that but that does not work!:

    <li<?php if (is_page('96=&child_of=96')) { echo " class=\"current\"";}?>>

    hope you can help me

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘add class “current” to navigation list item if a child page is selected?’ is closed to new replies.
Skip to toolbar