Problem styling pages and their subpages separately (3 posts)

  1. bagosta
    Posted 9 years ago #

    I'm having a template problem involving listing pages in the sidebar with sub-page, I've built off of the solution referenced here:


    I have a problem with Fold Page List's implementation. I'd like to style the "page_folder" ancestor separately from the child "page_items", however I cannot. The ancestor and children are both wrapped in an LI tag that doesn't terminate until after the child items, making anything done to the parent inherited by the children.

    The resultant html:

    <li class="page_item current_page_item page_folder">Ancestor
    <li class="page_item">Child One</li>
    <li class="page_item">Child Two</li>
    <li class="page_item">Child Three</li>

    And the php:

    // get id of current page
    $g_page_id = $wp_query->get_queried_object_id();
    // find ancestor pages
    $ancestors = _wswwpx_page_get_ancestor_ids($g_page_id);
    // find topmost ancestor
    $ancestor = reset($ancestors);
    // build args
    $args = "child_of=".$ancestor ."&sort_column=menu_order&title_li=";
    wswwpx_fold_page_list ($args, 2); ?>

    Ideal html:

    <li class="page_item current_page_item page_folder">Ancestor</li>
    <li class="page_item">Child One</li>
    <li class="page_item">Child Two</li>
    <li class="page_item">Child Three</li>

    Note how the UL is outside of the first LI. This is important to me so I can have ancestors use a separate style from the children, with a unique background image, ems size, and dynamic highlighting when that ancestor's page is selected.

    Am I doing something wrong? Is there a way for me to work around this or is this a bug to be fixed in the way WP outputs the children?

  2. bagosta
    Posted 9 years ago #

    OK, through some helpful CSS hints from the author of Fold Page List.. I managed to fix the highlighting problems.

    #leftcolumn a {text-decoration:none;color:#ffffff;}
    #leftcolumn a:hover {color:#fdae00;}
    #leftcolumn .current_page_item a{color:#fdae00;}
    #leftcolumn .current_page_ancestor a{color:#fdae00;}
    #leftcolumn .page_folder ul a{color:#ffffff;}
    #leftcolumn .page_folder ul a:hover{color:#fdae00;}
    #leftcolumn .page_folder ul .current_page_item a{ color:#fdae00;}

    Sets style of all links
    sets hover for all links
    Highlights active page link (only touches parents with or without child)
    Highlights parent with active child page link
    Sets all children to "normal", not highlighted when parent page link is
    Sets hover for children link
    Highlights active child page link

  3. chicoman98
    Posted 9 years ago #

    Thank you sooo much bagosta! I've been trying to figure out how to style 2nd level pages for hours. I kept having problems with inheritance but your css saved me. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic