Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • inspirationbit

    (@inspirationbit)

    Hi there,
    after a couple hours of searches, trials and errors, I found the solution. Here’s the code:

    <?php
    
    /* if the current pages has a parent, i.e. we are on a subpage */
    if($post->post_parent){
        $parent_title = get_the_title($post->post_parent);
        //$children = wp_list_pages("title_li=&include=".$post->post_parent."&echo=0"); // list the parent page
        $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); // append the list of children pages to the same $children variable
    }
    
    /* else if the current page does not have a parent, i.e. this is a top level page */
    else {
        $parent_title = get_the_title($post->ID);
        //$children = wp_list_pages("title_li=&include=".$post->ID."&echo=0");
        $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); // form a list of the children of the current page
    }
    
    /* if we ended up with any pages from the queries above */
    if ($parent_title) { ?>
        <h2><?php echo $parent_title; ?></h2>
    <?php } 
    
    if ($children) { ?>
        <ul class="submenu">
            <?php echo $children; /*print list of pages*/ ?>
        </ul>
    <?php } ?>

    Randa, did you check the post slugs? When you manage the posts in WordPress, you said you can see them all as published. Did you compare the URIs there with the ones on the site links? Can you Preview the published posts from WordPress Admin?

Viewing 2 replies - 1 through 2 (of 2 total)