• I’ve tried every custom pages widget I can find – King’s, “Custom Sub Pages”, Folding Pages, etc. What I want to happen is this:

    When on a parent page, I’d like a page navigation menu like so:

    ==Page 1
    ==Page 2
    ==Page 3

    (i’d label Parents 1, 2, 3, but only page 3 has children.)

    When I go to a parent page with children (i.e. if I open Page 3):

    ==Page 3
    ====Child 1
    ====Child 2
    ====Child 3

    then when I go to a child under that (i.e. if I open Child 1)

    ==Child 1
    ====Grandchild 1
    ====Grandchild 2
    ====Grandchild 3

    In simple terms, I want to show only two ‘levels’ of my page hierarchy(sp?), the ‘level’ I am on, and the children of that level. I don’t care if its on one widget/list/block or two, but if its in two I’d like it if the list for my children pages only shows up on the parent page – there’s a widget that does this, but it won’t let me limit the depth of the display: I either show all of the children, or none. In other words, every page shows up like this:

    Parent
    ==Child 1
    ====G.Kid 1
    ====G.Kid 2
    ====G.Kid 3
    ==Child2
    ====G. kid 1
    ====G. kid 2
    ===Child 3

    When I just don’t want to show that much depth all at once – itll take up a huge vertical space on the screen. I might be able to do it using the built-in pages PHP function, but I can’t put PHP in a sidebar (it just spews out the code, not what it does). Can anyone give me a hand?

    EDIT: You can see what I’m working with at https://wepushthebuttons.info

Viewing 8 replies - 1 through 8 (of 8 total)
  • I have a similar request. I’d only like to show the grandchildren on the child and grandchild pages. I.e. the parents and children always show up. The grandschildren only appear if someone clicks on the children pages. But then all three levels must appear on the grandchildren pages.

    I’m currently using a workaround of listing the pages with a depth of 1 first, and then showing levels 2 and 3 if clicked on. It’s not ideal, because the menu is split up – you can see it at https://www.floorstyle.nl/ondervloeren

    Does anyone have a better idea? Help. Thank you.

    Easy! Find in wp-includes the file post-template.php. Around line 593 is:

    function wp_list_pages($args = '') {
    	$defaults = array(
    		'depth' => 0, 'show_date' => '',
    		'date_format' => get_option('date_format'),
    		'child_of' => 0, 'exclude' => '',
    		'title_li' => __('Pages'), 'echo' => 1,
    		'authors' => '', 'sort_column' => 'menu_order, post_title',
    		'link_before' => '', 'link_after' => ''
    	);

    Change 'depth' => 0, to 'depth' =>1

    Hi,
    I have a similar issue, but not sure if I’m looking for the same result.
    What I am trying to do with the menu is to make it so it displays the full depth of the current page, but not the others.

    So if this is my hierarchy:

    Parent 1
    Parent 2 -> Child 2.1
    Parent 3 -> Child 3.1
    -> Child 3.2
    -> Child 3.3 -> Grandchild 1
    -> Grandchild 2

    When I am on Parent 1 I would only like to see the Parents level of menu.
    If I am on Parent 2, I would like to see His Child 1 but not Parent 3’s children

    And I would only like to see the grandchildren of Child 3 when I am actually on that page, but not on Child 2 or Child 1.

    I hope that makes some sense.

    I have used this code that works great at the first two levels, but it doesn’t work for the Granchildren level. And after trying to modify it I haven’t figured out how to get it to do what I want.

    <!-- FIRST ONLY DISPLAY THE 1st LEVEL -->
    
    <?php wp_list_pages('title_li=&depth=1'); ?> 
    
    <!-- THEN DISPLAY THE CHILDREN IF THERE ARE ANY -->
    
    <?php if($post->post_parent)
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
      else
      $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
      if ($children) { ?>
    <ul>
      <?php echo $children; ?>
    </ul>
      <?php } ?>

    Is there any way of extending this to the grandchildren?
    any tips or suggestions would be very appreciated.

    Thanks,

    nagore

    bump!

    Bump again. I’ve also been trying to only show the grandchildren, expand the parent-child thing to child-grandchild. Any ideas?

    Looking for this solution as well!

    My guess, after seeing this question OVER and OVER again is that it’s either really hard to do, or not possible.

    I’d love to hear a developer’s thoughts on the matter.

    Thanks in advance!

    Ok, I figure it out. You have to use this extension: https://www.webspaceworks.com/resources/wordpress/30/ (click downloads on left to install).

    Then after activating, I simply used this:

    <?php
    // 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=<h5>hide</h5>&amp;depth=3&amp;child_of=".$grandParent);
    ?>

    Here is working example: https://www.thebestcoffee.com/local/community/coffee-college/brewing-coffee-basics/

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Subpages and their kiddos’ is closed to new replies.