WordPress.org

Support

Support » Plugins and Hacks » Child and Parent Pages

Child and Parent Pages

  • Hi, I’m trying to figure out how to make WordPress give a child’s Parent Page the .current_page_item class when I navigate to the child pag. See http://www.skydogtech.com, and go to the “Work” tab. When I select one of those child pages, I’d like for “Work” to stay highlighted.

    In my header.php I’m using the following php to highlight the home page manually for me (because I’m using the static page plugin), and I think I should be able to add a little php that says “if the parent of the current page is the work page, then add current_page_item”. My problem is that I don’t know enough php to do it.. can anyone help?

    Thanks so much.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <?php
    $pg_li='page_item'; //Base CSS class
    $homepage='/'; //The homepage directory
    $URI=$_SERVER['REQUEST_URI']; //Gets the requested URI
    if ($URI == $homepage) {$pg_li .=' current_page_item';} //If the Requested URI is our homepage, add current_page_item
    ?>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Child and Parent Pages’ is closed to new replies.
Skip to toolbar