Title: Parent page highlightning
Last modified: August 19, 2016

---

# Parent page highlightning

 *  [schmolzer](https://wordpress.org/support/users/schmolzer/)
 * (@schmolzer)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/parent-page-highlightning/)
 * Hi!
 * Link to the website:
 * [http://trollback.se/urskog/](http://trollback.se/urskog/)
 * I want to highlight my parent and grandparent pages, when on a child page. I 
   have two different menus, so the code have to tell for example “products” to 
   be current when it’s grandchild page is active. So the code have to tell both
   the parent page to be “current” and the child page to be “current2”.
    And I don’t
   know how. Please help me, I have looked at other posts and found this piece of
   code :
 *     ```
       <?php>
       function has_parent($post, $post_id) {
         if ($post->ID == $post_id) return true;
         else if ($post->post_parent == 0) return false;
         else return has_parent(get_post($post->post_parent),$post_id);
       }
       ?>
   
       <?php global $wp_query; if( has_parent($wp_query->post), 3) :?>
       <?php endif; ?>
       ```
   
 * But I don’t know how I’m supposed to write to make it work!
    Thank you in advance
 * I have two menus:
 *     ```
       <div id="topNav">
       	<div id="topNav_topShadow"></div>
           <div id="topNav_content">
   
           	<ul id="menu">
                              <li class="urskog"<?php
                       if (is_page('urskog'))
                       {
                       echo " id=\"current\"";
                       }?>>
                       <a>/urskog">Urskog</a>
   
                    <li class="products"<?php
                       if(is_page('products'))
                       {
                       echo " id=\"current\"";
                       }?>>
                       <a>/products/lov/walnut">Products</a>
   
                     <li class="press"<?php
                       if(is_page('press'))
                       {
                       echo " id=\"current\"";
                       }?>>
                       <a>/press">Press</a>
   
                    <li class="contact"<?php
                       if(is_page('contact'))
                       {
                       echo " id=\"current\"";
                       }?>>
                       <a>/contact">Kontakt</a>
   
               <li class="separator">
       ```
   
 * My second menu:
 *     ```
       <ul>
       				<li class="mainNav_lov"<?php 
   
       					if (is_page('lov')) 
   
       					{
       					echo " id=\"current2\"";
   
       					}?>>
   
       					<a>/products/lov/walnut">Lov</a>
   
       				<li class="mainNav_miniLov"<?php 
   
       					if (is_page('minilov')) 
   
       					{
   
       					echo " id=\"current2\"";
   
       					}?>>
   
       					<a>/products/minilov/walnut">Mini Lov</a>
   
       				<li class="mainNav_pinne"<?php 
   
       					if (is_page('pinne')) 
   
       					{
   
       					echo " id=\"current2\"";
   
       					}?>>
   
       					<a>/products/pinne/walnut">Pinne</a>
   
       				<li class="mainNav_pokus"<?php 
   
       					if (is_page('pokus')) 
   
       					{
   
       					echo " id=\"current2\"";
   
       					}?>>
   
       					<a>/products/pokus/walnut">Pokus</a>
   
       				<li class="mainNav_kil"<?php 
   
       					if (is_page('kil')) 
   
       					{
   
       					echo " id=\"current2\"";
   
       					}?>>
   
       					<a>/products/kil">Kil</a>
   
       				<li class="mainNav_skate"<?php 
   
       					if (is_page('skate')) 
   
       					{
   
       					echo " id=\"current2\"";
   
       					}?>>
   
       					<a>/products/skate/walnut">Skate</a>
   
       			<li class="mainNav_drivved"<?php 	
   
       				if (is_page('drivved'))
   
       				{
       				echo " id=\"current2\"";
   
       				}?>>	
   
       				<a href="<?php bloginfo('url') ?>/products/drivved">Drivved</a>
   
       			</li>
                                       <li class="mainNav_separator">
   
       </ul>
       ```
   

Viewing 1 replies (of 1 total)

 *  Thread Starter [schmolzer](https://wordpress.org/support/users/schmolzer/)
 * (@schmolzer)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/parent-page-highlightning/#post-1340411)
 * Anyone have an idea how to fix this ?

Viewing 1 replies (of 1 total)

The topic ‘Parent page highlightning’ is closed to new replies.

## Tags

 * [child](https://wordpress.org/support/topic-tag/child/)
 * [grandchild](https://wordpress.org/support/topic-tag/grandchild/)
 * [grandparent](https://wordpress.org/support/topic-tag/grandparent/)
 * [page](https://wordpress.org/support/topic-tag/page/)
 * [parent](https://wordpress.org/support/topic-tag/parent/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [post](https://wordpress.org/support/topic-tag/post/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [schmolzer](https://wordpress.org/support/users/schmolzer/)
 * Last activity: [16 years, 4 months ago](https://wordpress.org/support/topic/parent-page-highlightning/#post-1340411)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
