Title: Conditional links
Last modified: August 31, 2016

---

# Conditional links

 *  [gulliver](https://wordpress.org/support/users/gulliver/)
 * (@gulliver)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/conditional-links/)
 * 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)

 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/conditional-links/#post-7197798)
 * 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](https://wordpress.org/support/users/gulliver/)
 * (@gulliver)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/conditional-links/#post-7197799)
 * 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.
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/conditional-links/#post-7197867)
 * 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.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/conditional-links/#post-7197867)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
