Submit Your Article Forum Rules

Results 1 to 6 of 6

Thread: Wordpress Sidebar - List Only Grandchildren Pages

  1. #1
    WebProWorld MVP morestar's Avatar
    Join Date
    Jun 2007
    Location
    Toronto, Ontario
    Posts
    4,164

    Wordpress Sidebar - List Only Grandchildren Pages

    So there really is nothing out there in search and find land that will help me. I don't know how this can be so complicated but I need some help coding something that will display only the grandchildren of a parent page.

    Does anyone know how to do this? It looks like since there isn't anything specific out there that I'm either not searching with the right terms or this has to be figured out right here and now.

    Either way anyone's assistance or guidance in this matter is appreciated - thank you.

  2. #2
    WebProWorld MVP morestar's Avatar
    Join Date
    Jun 2007
    Location
    Toronto, Ontario
    Posts
    4,164
    For further clarification. There are hundreds of scripts etc. out there that display child and grandchild pages according to which page your on but that's not what I'm looking for.

    I simply need help figuring out how to display on any page I want, (mainly top level pages, ie. home, about, contact etc.) a sidebar menu that displays the grandchild pages of the parent page with an id of 182 (for instance).

    Thank you, anyone who can help with this.

  3. #3
    Moderator chrisJumbo's Avatar
    Join Date
    Oct 2005
    Location
    Near Sacramento, CA
    Posts
    1,198
    How about using Custom Fields? We have pages with children and a custom field set as to whether or not to show the page in the top navigation. I'm sure you could do something similar for grandchildren.

    The code for the nav:
    Code:
    <ul id="nav">
      <?php wp_list_pages('depth=1&sort_column=menu_order&title_li&meta_key=edc-show-in-nav&exclude=157&meta_value=yes'); ?>
    </ul>

  4. #4
    WebProWorld MVP morestar's Avatar
    Join Date
    Jun 2007
    Location
    Toronto, Ontario
    Posts
    4,164
    I tried and tried with this Chris, and thank you, but to no avail...

  5. #5
    Moderator chrisJumbo's Avatar
    Join Date
    Oct 2005
    Location
    Near Sacramento, CA
    Posts
    1,198
    How about brute force and use the "include" parameter to only show the page IDs that you want? Or are there too many pages to deal with?

    I could see potential with a case statement keying off of the page names if you need to handle more than one parent-to-grandchild combo. Seems like it should be much easier then this though. :O)

  6. #6
    WebProWorld MVP morestar's Avatar
    Join Date
    Jun 2007
    Location
    Toronto, Ontario
    Posts
    4,164
    Quote Originally Posted by chrisJumbo View Post
    How about brute force and use the "include" parameter to only show the page IDs that you want? Or are there too many pages to deal with?
    Thanks Chris. Yes I think I'll brute force it in the way of just writing the damn thing myself using some of the hooks rather than try to find someone who's done it cause I tell ya I've searched far and wide and am shocked nothing is out there.

    So I'll go and try to write it now...I'll get back to you with the code...this shouldn't be too hard...

    I'll just grab the id and list pages at the third tier with a grandparent of that ID...or maybe I'll search grandparent rather than grandchild(ren).

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •