Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Hi there Wordpress guru's,

i running up against a problem. I've my parent pages in the header.php and childpages in page.php. when i clicked on one of the subpages in a parent page i want that my parent page stay active. How can i get that done?

in my header.php i've the following code:

<ul id="mainNav">
 <?php wp_list_pages('sort_column=menu_order&exclude=2&depth=1&title_li='); ?>
</ul>

page.php

<?php if($post->post_parent)
            $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else
            $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
            if ($children) { ?>
            <div id="subPages">
            <ul>
            <li class="root"><?php echo '<a href="'.get_permalink($post->post_parent).'">'.get_the_title($post->post_parent).'</a>';?></li>
            <?php echo $children; ?>
            </ul>
            </div>
            <?php } else { ?>
        <?php } ?>

U can see the example : here when you click on one of the subpages i want that the parent page (the tab above) stays active.

tnx for advance.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

http://codex.wordpress.org/Function_Reference/wp_list_pages#Markup_and_styling_of_page_items

style .current_page_parent and/or .current_page_ancestor the same as .current_page_item

share|improve this answer
    
thank you very much dude:) it works great:). –  Navid Aug 14 '11 at 4:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.