• Hello hello.

    Had a good thorough search in the Codex and on Google for a solution to this, but not seen a squeak on it.

    Is there a technique to make the PARENT of the CURRENT PAGE’S PARENT highlighted in a 4-level page menu? I’m talking grand-parents and great-grand-parents. I want the page item to hover red before being selected, stay red when selected, and stay red when its child and child’s child are selected.

    Currently I have my css in this format (it is very unwieldy, and I’ve stripped out the non-relevant code):

    /*sidebar list level1 */
    #sidebar ul {}
    #sidebar ul li {}

    /*sidebar list level2 */
    #sidebar ul li ul {}
    #sidebar ul li ul li {}

    #sidebar ul li ul li.current_page_item a, #sidebar ul li ul li.current_page_parent a {
    color:red
    }

    /*sidebar list level3 */
    #sidebar ul li ul li ul {}
    #sidebar ul li ul li ul li.page_item a {}

    #sidebar ul li ul li ul li.page_item a:hover, #sidebar ul li ul li ul li.current_page_item a, #sidebar ul li ul li ul li.current_page_parent a {
    color:red
    }

    /*sidebar list level4 */
    #sidebar ul li ul li ul li ul {}
    #sidebar ul li ul li ul li ul li.page_item a {}

    #sidebar ul li ul li ul li ul li.page_item a:hover, #sidebar ul li ul li ul li ul li.current_page_item a, #sidebar ul li ul li ul li ul li.current_page_parent_parent a {
    color:red
    }

    The highlighting of current page parents works for two levels, but not three or four. I’ve tried many permutations of current_page_parent, page_parent etc, but none of it reaches back far enough.

    The html/php is:

    <?php
    global $notfound;
    if (is_page() and ($notfound != ‘1’)) {
    $current_page = $post->ID;
    while($current_page) {
    $page_query = $wpdb->get_row(“SELECT ID, post_title, post_status, post_parent FROM $wpdb->posts WHERE ID = ‘$current_page'”);
    $current_page = $page_query->post_parent;
    }
    $parent_id = $page_query->ID;
    $parent_title = $page_query->post_title;

    // if ($wpdb->get_results(“SELECT * FROM $wpdb->posts WHERE post_parent = ‘$parent_id’ AND post_status != ‘attachment'”)) {
    if ($wpdb->get_results(“SELECT * FROM $wpdb->posts WHERE post_parent = ‘$parent_id’ AND post_type != ‘attachment'”)) {
    ?>

    • <h4 class=”sidebartitle”><?php _e(‘PAGES MENU/LIST’); ?></h4>
      <ul class=”list-page”>
      <?php wp_list_pages(‘sort_column=menu_order&title_li=&child_of=’. $parent_id); ?>
    • <?php comments_template(); ?>
      <?php } } ?>

      Any ideas, anyone?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘highlighting parent of current_page_parent in 4-level menu list’ is closed to new replies.