WordPress.org

Ready to get started?Download WordPress

Forums

list pages and subpages by section (child_of and ?) (12 posts)

  1. imbri
    Member
    Posted 9 years ago #

    I have pages 3 levels deep. I'd like to list all pages above the current level as well as the pages in the level and the pages directly under that page. I can't figure it out. I can get the children of the page or I can get every page, but I can't get just the pages in a section. That sounds awfully confusing, so let's make a little page structure/visual example...

    Site Map

    - People
    - Places
    - - Here
    - - There
    - Things
    - - shiny things
    - - - tin foil
    - - - mirror
    - - - magic stone
    - - ugly things
    - - scary things
    - - - my neighbor's cat
    - - - bumpy knights

    As it is now, if you were on the tin foil page, you'd not see anything in the side bar. If you went up a level, to shiny things, you'd see tin foil, mirror, & magic stone in the sidebar. What I want is for people on the tin foil page to see...

    - People
    - Places
    - Things
    - - Shiny things
    - - - Tin Foil
    - - - Mirror
    - - - Magic Stone
    - - Ugly Things
    - - Scary Things

    And, let's say they went to the Places Page, I'd want them to see:

    - People
    - Places
    - - Here
    - - There
    - Things

    Pretty basic Menu101 sort of stuff, right. Why can't I figure this out then?! I should at least be in Menu102 by now :) I'm sure it's right there and I just can't see it, but I've searched, I've been through the codex, I've messed with the code and nothing seems to want to play nicely.

    Here's the latest working code: wp_list_pages('child_of=' . $id . '&title_li=

    Is there a sibling tag? A grandparent tag? An everything next to, above you, and beneath you tag? That's the one I want... next to, above, & below.

    Thanks for the help!

  2. Rob Poitras
    Member
    Posted 9 years ago #

    I have been trying something similar
    There is some docs in the codex related to this:
    http://codex.wordpress.org/Template_Tags/wp_list_pages

    I havent played with the get_links stuff yet but I plan to tomorrow or maybe tonight.

    What I did for my site is a bit labor intensive (kinda)
    I just created a link category. In the link cateogory I would have specific links I would only want displayed.
    Then I created a bunch of templates for the pages.

    Does that make sense?
    I could email you more details and the code I used, i know this isnt the same thing you are looking for but it kinda gets it done. I think it gives you more control on how you want the sidebar to appear.
    Oh another thing, I deleted the get_sidebar thing. I just did a sidebar within the page template.

  3. imbri
    Member
    Posted 9 years ago #

    That makes perfect sense. It is a bit labor intensive, though not terribly so. I'll give it a go until I find a more dynamic solution. Surely with all the php wizards around this place, there's someone that knows how it can be done. Someone?

    As for the sidebar: I prefer a seperate template. I tend to break stuff when I mess with it. Better to just break one bit than the whole bit.

    Thanks much for your help... at least I have something to get me going for a bit.

  4. mumkin
    Member
    Posted 9 years ago #

    *bump* because I'm looking to accomplish the same. I wish to display all top-level categories, with nested children of the currently selected category as well.

    It seems like the kind of functionality that wp_list_cats should have built-in. Much searching of support reveals lots of dhtml and js suggestions, but I don't want or need dynamic expansion -- I'm merely looking for a solution that builds a category listing like this when you're at root (or in a cat without children):

    Categories:
    1 Apples
    2 Oranges
    3 Peaches

    and this, when in Category 2:

    Categories:
    1 Apples
    2 Oranges
      2.1 Blood Oranges
      2.2 Navel Oranges
      2.3 Seville Oranges
    3 Peaches

  5. Bob44
    Member
    Posted 9 years ago #

    Yes yes - this is what I am also after. Have tried everything I am capable of but nothing yet... Wondered if anyone could help. I see the AlexKing.org site has something similar to what I'd like to expand and contract categories.

    Also found this link which looks great but have no idea how to add it to a wordpress site.
    http://evolt.jeffhowden.com/jeff/code/toggle_display.cfm

    Anyone like to take a crack at it?

    Many thanks

    bob

  6. vkaryl
    Member
    Posted 9 years ago #

    It's just a js that you place in the <head> of your page (probably in the header.php, though sometimes the index.php is where that tagset resides).

    Then you use his html/css example to recode your list members to call the js to collapse and expand. Will work great unless you have a lot of vistors with js disabled.

  7. roblgs
    Member
    Posted 9 years ago #

    Take a look at the new Fold Page List plugin announced on this threadwordpress.org/support/topic/31760.

  8. theraven
    Member
    Posted 8 years ago #

    I tried Fold Page Plugin... awesome!!
    But, I have to stick with parameters in wp_list_pages.

    I want the parameter to display only parent pages on the sidebar. I am familiar with exclude pages, but I would have to edit my sidebar everytime I add a subpage (not good solution)

    Example:
    * BIo (page=3)
    - Frank (page=4)
    - Jo (page=5)
    - Bill (page=6)

    Not Good:
    <?php wp_list_pages('exclude=4,5,6&title_li=<h2>' . __('Pages') . '</h2>' ); ?>

    Doesn't Work:
    <?php wp_list_pages('include=3&title_li=<h2>' . __('Pages') . '</h2>' ); ?>

    1. I don't think "include only" exists.

    2. Is there a way to display parents only and no children? I know the child_of parameter... can it be used here to exclude children?

  9. TechGnome
    Moderator
    Posted 8 years ago #

    There's a level parameter.... set it to 0...

    Nope, wait, I sit corrected. It's "depth" and set it to 1.

    <?php wp_list_pages('depth=1&title_li='); ?>

    -tg

  10. Jonas Grønås Drange
    Member
    Posted 8 years ago #

    Is this still a problem?

  11. roblgs
    Member
    Posted 8 years ago #

    Can you be a bit more specific. Is what still a problem?

    Rob

  12. nagyv
    Member
    Posted 8 years ago #

    Although the original author did not posted for a while, the problem still exists. I have tried to accomplish something very similar. I have this page structure:

    - People
    - Places
    - - Here
    - - There
    - Things
    - - shiny things
    - - - tin foil
    - - - mirror
    - - - magic stone
    - - ugly things
    - - scary things
    - - - my neighbor's cat
    - - - bumpy knights

    In general I list only the first level of them, that works great, but at some point I would like to list a given branch of a given (this is important!) node.
    I could find out how to prepare the unordered menu list by backward walking on the page-parent structure, until finding the page with the given ID, and then I run a wp_list_pages(child_of=given-ID).

    The only problem is that it does not set the current_item class in the unordered list.

    I use this code before the content loop:

    <?php
    $parent[0] = $tmp = $post;
    while($parent[0]->post_parent != 10){
    $parent = query_posts('page_id=' .$parent[0]->post_parent);
    }
    ?>
    <div id="menu">
    <div class="header">guid;?>"><?php echo $parent[0]->post_title;?></div>

      <?php
      wp_list_pages('title_li=&sort_column=menu_order&child_of='.$parent[0]->ID); ?>

    </div>

    <?php
    query_posts('page_id=' .$tmp->ID);
    unset($parent, $tmp);
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.