WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Fold Page List plugin (17 posts)

  1. mzimmers
    Member
    Posted 6 years ago #

    Hi -

    I'm using the Fold Page List plugin (from http://www.webspaceworks.com/resources/wordpress/30/). It works wonderfully, except
    that when I travel down to a second-level child page, the link to the parent page (a first-level child page) disappears, and the user has no way to travel back.

    Any way to fix this, or is this just how it's going to be? Thanks.

  2. mzimmers
    Member
    Posted 6 years ago #

    * bump *

    here's the code fragment I'm using...it should apply to wp_list_pages() as well:

    <?php
            $thispage = $wp_query->post;
    
            if ($thispage->post_parent!=0)
            {
                wswwpx_fold_page_list("title_li=&child_of=".$thispage->post_parent);
            }
            else
            {
                wswwpx_fold_page_list("title_li=&child_of=".$thispage->ID);
            } ?>

    What can I add to this to ensure that when I go to a sub-child, I get the child page above it listed as well?

  3. mzimmers
    Member
    Posted 6 years ago #

    Marked as resolved because I'm going to take a different tack on this one.

  4. quirksmode
    Member
    Posted 6 years ago #

    Hi,

    I am having exactly the same problem, what was your final solution?

  5. roblgs
    Member
    Posted 6 years ago #

    Hi,

    The problem with the above code fragment is that it only handles the case children of the current page or children of its parent... If the page list you are trying to generate is more than one generation above the current page, then it simply won't work.

    The Fold Page List plugin includes an internal function (_wswwpx_page_get_ancestor_ids) to return the entire ancestral tree as an array, from the root of the site to the current page (the order can also be reversed), allowing you to always get the id for any page ancestor. Simply feed it the id of the current page, and then select the id you need from the output array to get the navigation you require. For example, if $pageID is the current page located at the 4th level, then its grand-parent will be at the second position in the array of ancestors.

    $ancestors = _wswwpx_page_get_ancestor_ids($pageID);
    $grandParent = $ancestors[1];
    wswwpx_fold_page_list("title_li=&child_of=".$grandParent);

    Should do the trick.

    Cheers

    Rob

  6. roblgs
    Member
    Posted 6 years ago #

    Hi,

    I've just posted an explanation of how to build multi-level page navigation lists which goes into a little more detail than above.

    Cheers

    Rob

  7. chabotjeff
    Member
    Posted 6 years ago #

    Hi. I've installed Foldpages and works great. I have a question about the order though. Above it was mentioned you can "reverse" the order. Right now, my child cats that run 1-6 in WordPress order are showing up reversed on my site. So #6 first, then down to #1. Is there a simple solution?

  8. chabotjeff
    Member
    Posted 6 years ago #

    There is an error on my part where it says "my child cats" - I meant "child pages" - not categories. Also, when I get a resolution to this I'll post elsewhere - didn't mean to post in resolved topic.

  9. hardijs
    Member
    Posted 5 years ago #

    roblgs: where is the description. it shows the empty page instead of how to build multi-level page navigation lists
    thanks.

  10. Robert Simpson
    Member
    Posted 5 years ago #

    Hi folks,

    I've been in contact with Rob via email, I don't think he has seen this page updated yet so I'll post my solution in the meantime.

    This will give you a multi level page navigation list right to the root of your site:

    $g_page_id = $wp_query->get_queried_object_id();
    $ancestorIDs = _wswwpx_page_get_ancestor_ids($g_page_id);
    $grandParent = $ancestorIDs[0];
    wswwpx_fold_page_list("title_li=<h2>Navigation</h2>&sort_column=menu_order&child_of=".$grandParent);

    ...and this will give you your top level and everything underneath seperately:

    // Top level navigation
    wswwpx_fold_page_list ('depth=1&sort_column=menu_order&title_li=<h2>Top Navigation</h2>');
    
    // Sub level navigation
    $g_page_id = $wp_query->get_queried_object_id();
    $ancestorIDs = _wswwpx_page_get_ancestor_ids($g_page_id);
    $grandParent = $ancestorIDs[1];
    wswwpx_fold_page_list("title_li=<h2>Sub Navigation</h2>&sort_column=menu_order&child_of=".$grandParent);

    Hope that helps :)

    Cheers,
    Robert

  11. guzh
    Member
    Posted 5 years ago #

    Hi!

    I've got a problem, my PHP-skills isn't that well, but is it possible to get a horizontal menu like this with the Fold Page List Plugin?

  12. schoffelman
    Member
    Posted 5 years ago #

    @RSimpson - thanks for explaining a little further, it's helped out quite a bit.

  13. maestro42
    Member
    Posted 5 years ago #

    @RSimpson - that is very helpful, thank you!

    My question is this, I have an About Page. I have 2 children under the About Page. Under each child, I have 3 grandchildren pages.

    What I am trying to do is show the following Navigation structure:

    About
    -Child 1
    --Gchild 1.1
    --Gchild 1.2
    --Gchild 1.3
    -Child 2
    --Gchild 2.1
    --Gchild 2.2
    --Gchild 2.3

    I am trying to get it to show this full structure, no matter which page on the chain you are at. I can get it to show the full structure okay, but it includes ALL pages in the WordPress system. Is there a way to limit the list to ONLY include pages that fall under the About Page? (i.e. maybe with $grandParent = $ancestorIDs[1]; somehow)

  14. Anonymous
    Unregistered
    Posted 5 years ago #

    @RSimpson - legend! That is exactly what I have been looking for.

    @maestro42 - I have been trying to get the same nav structure. I modified RSimpson's code sample as follows:

    <!-- Sub level navigation-->
    <!-- This first bit does the Title entry eg "About"-->
    <li>
    <ul>
    <h2><?php
    $g_page_id = $wp_query->get_queried_object_id();
    $ancestorIDs = _wswwpx_page_get_ancestor_ids($g_page_id);
    $titlePage = $ancestorIDs[1];
    wp_list_pages("title_li=&depth=1&include=".$titlePage);
    ?></h2>
    <!-- Then this bit does the other pages-->
    <?php
    $g_page_id = $wp_query->get_queried_object_id();
    $ancestorIDs = _wswwpx_page_get_ancestor_ids($g_page_id);
    $grandParent = $ancestorIDs[1];
    wswwpx_fold_page_list("sort_column=menu_order&child_of=".$grandParent);
    ?>
    </ul>
    </li>

    Used in conjunction with the modification to the plugin outlined by DoodleBee here this should give you what you are looking for. Note: this is dirty hack job so I won't guarantee it's even close to the best way to do this. If anyone wants to suggest a more elegant solution please feel free :-)

  15. Anonymous
    Unregistered
    Posted 5 years ago #

    Apologies - a little premature there... This code snippet, used in conjunction with the Doodlebee rewrite, gives you a full chain of links when on a page in the chain, and nothing when on any other page.

    <!-- Sub level navigation-->
    <?php
    $g_page_id = $wp_query->get_queried_object_id();
    $ancestorIDs = _wswwpx_page_get_ancestor_ids($g_page_id);
    $titlePage = $ancestorIDs[1];
    $childIDs = _wswwpx_page_get_child_ids($titlePage);
    if (is_array($childIDs))
    {
    ?><li><ul><h2><?php
    wp_list_pages("title_li=&depth=1&include=".$titlePage);
    ?></h2><?php
    $grandParent = $ancestorIDs[1];
    wswwpx_fold_page_list("sort_column=menu_order&child_of=".$grandParent);
    ?></ul></li><?php
    }
    ?>
  16. maestro42
    Member
    Posted 5 years ago #

    thanks! I will take a look at this and see what I can come up with.

  17. midnightoilproductions
    Member
    Posted 5 years ago #

    Thanks everyone. Here is another modification of the code using the FoldPages to list the parents and the siblings in separate menus (note that I have my css classes included here as well which you'll need to modify).

    <!-- level 2 menu begin -->
    
    <div class="submenuwrap">
    <ul class="submenu">
    <?php
    $g_page_id = $wp_query->get_queried_object_id();
    $ancestorIDs = _wswwpx_page_get_ancestor_ids($g_page_id);
    $titlePage = $ancestorIDs[1];
    wp_list_pages("title_li=&child_of=".$titlePage."&depth=1");
    ?>
    </ul>
    </div>
    
    <!-- level 2 menu end -->
    
    <!-- level 3 menu begin -->
    
    <?php
      if($post->post_parent)
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&sort_column=menu_order&sort_order=DESC");
      else
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&sort_column=menu_order&sort_order=DESC");
      if ($children) { ?>
    <div class="newslistwrap">
    <ul class="newslist">
    <h5 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h5>
    <?php echo $children; ?>
    </ul>
    </div>
    <?php } ?>
    
    <!-- level 3 menu end -->

Topic Closed

This topic has been closed to new replies.

About this Topic