WordPress.org

Ready to get started?Download WordPress

Forums

Child and Parent Pages (5 posts)

  1. sugoo
    Member
    Posted 8 years ago #

    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>

  2. strugglefish
    Member
    Posted 8 years ago #

    Hi did you find out how to do this?

  3. sugoo
    Member
    Posted 8 years ago #

    no, nothing yet... you?

  4. strugglefish
    Member
    Posted 8 years ago #

  5. sugoo
    Member
    Posted 8 years ago #

    that's it! thanks so much!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags