Support » Fixing WordPress » current_page_parent is wrong?!

  • I’m using the a call to wp_list_pages() in my sidebar and would like to setup some JS/CSS to hide all the sub-pages of other parent-pages. My page structure is:

    # Visitors’ Guide (page-id-7)
    * Events Calendar
    * Island News
    * Services
    * Island History & Culture
    * Attractions
    * Accommodations
    * Find Local Businesses
    * Directions & Travel Info
    # Getting Here
    * Island Map
    # About
    * Site Map
    * For Advertisers

    For some reason, on some pages that are children of Visitors’ Guide, .current_page_parent is assigned to the wrong li.

    For example:
    – when Island News or Events Calendar are the current page, Island news is assigned .current_page_parent
    – when Directions & Travel Info is the current page, Visitors’ Guide is assigned .current_page_parent (as it should be)

    The wierdest thing is that Events Calendar & Island News have a div #content with the class .parent-pageid-7 (as it should be), so it’s not messed up everywhere.

    Where do you think this is getting screwed up? (Deleting the Island News page and re-creating it did not help.)

Viewing 3 replies - 1 through 3 (of 3 total)
  • Is nobody responding because I put this question in the wrong section or because you’re not sure what’s going on?
    Thanks!

    If I’m getting this correctly, you want to display the sub pages (children) only if you are on that parent page.

    with the wp_list_pages you should be able to exclude the sub pages by setting the depth to 1. But to set it up by parent, I think you will need an if statement and will have to do it in your sidebar template.

    maybe someone else will have a better solution.

    @cdembinski thanks for the reply.
    To clarify: I’m hiding/showing the sub-pages using JavaScript, and it works fine *most* of the time. It isn’t working on particular pages because for some reason the .current_page_parent class is being applied incorrectly. I’m not sure how to troubleshoot this because it seems like a database error.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘current_page_parent is wrong?!’ is closed to new replies.