• Resolved nex2nun

    (@nex2nun)


    Trying to have both the parent and child page highlighted when viewing a child page. The child page highlights but the parent page does not. Anything I need to tweak with this?

    <?php //highlight 'Home' if not Page
    
    if ( is_page()) {
            $highlight = "page_item";
    
    } elseif ( is_page() && $post->post_parent )  {
    	$highlight = "page_item current_page_item current_page_parent";
    } else {
    	$highlight = "page_item current_page_item";
    }
    ?>

    Thanks in advance!

Viewing 1 replies (of 1 total)
  • Thread Starter nex2nun

    (@nex2nun)

    There I go, thinking outside the box again.

    I removed my previous conditional array and made sure I had the correct styles in place, those being:

    #nav .current_page_item a {
    	color: #264971;
    	background-color: #D8E7EC;
    }
    
    #nav .current_page_parent a {
    	color: #264971;
    	background-color: #D8E7EC;
    }

    And then adjusted my wp_list_pages a bit:

    <div id="nav">
    
    	<ul>
    		<li class="page_item <?php if (is_home()) { echo "current_page_item"; } ?>"><a href="<?php echo get_settings('home'); ?>">Home</a></li>
    		<?php wp_list_pages('title_li=&depth=1'); ?>
    	</ul> 
    
    </div>

    Kept child pages as they were:

    <?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) { ?>
                    <ul class="menu">
                    <?php echo $children; ?>
                    </ul>
                    <?php } ?>

    And all works well!

Viewing 1 replies (of 1 total)
  • The topic ‘Highlight Parent and Child pages’ is closed to new replies.