• Preferring something simpler to the standard WP menus, I’m using a conditional statement to add a ‘current’ highlight to a hard-coded page menu.

    I can get things working ok on a page and its parent, by using

    if ( is_page('programs') || '117' == $post->post_parent )' [where 117 is the page ID]

    But on lower-level pages the highlight is absent, and so I need to revise that code to cover all child pages of that parent, (and highlight the grandparent?) but have no idea how to.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You would need to be able to either hold all of the child ID’s in that node, or you’d need to work backwards from the most sub-sub-sub menu and move up the nodes applying a value to each parent as it goes.

    Thread Starter gulliver

    (@gulliver)

    Thanks.
    Sounds like that’s beyond my ability. I was hoping there was something simple – perhaps a way to replace the id of the immediate parent with that of the ultimate parent.

    There are some values available to each menu item (when you’re doing it the standrd WordPress way at least). If you’re trying to “roll your onw” then you have to put in the extra effort to make it work that way. It’s no teasy to do, and that’s why most people stick with the WordPress systems until they have more knowledge on how it all works.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Conditional links’ is closed to new replies.