• Hi all –

    I’m having a bit of a problem, and have absolutely no clue why.

    If I use

    <?php $current_page_id = $wp_query->post->ID;
                wp_list_pages("title_li=&child_of=$current_page_id&depth=1"); ?>
                </ul>

    It lists the children of a page with no problem.

    I’ve been trying to add a link to the parent above this.

    If I try many of the codes suggestions, like this:

    <?php
        if(!$post->post_parent){
             $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=1");
        }else{
    	  if($post->ancestors){
    		$ancestors = array_reverse($post->ancestors, true);
    		foreach($ancestors as $ancestor){
    			$ancestor = wp_list_pages("title_li=&child_of=".$ancestor."&echo=0&depth=1");
    			echo "<ul>";
    			echo $ancestor;
    			echo "</ul>";
    		}
    		$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=1");
    	}
    }
    if ($children) {
     	echo "<ul>";
     	echo $children;
     	echo "</ul>";
    }
    ?>

    It pulls nothing.

    I’ve also tried using <?php echo $post->post_title; ?>, and am getting the last blog post…which isn’t even on the page.

    Any thoughts? TIA!

Viewing 1 replies (of 1 total)
  • Thread Starter lynnema

    (@lynnema)

    So I got it to pull the query. I hadn’t reset the query in the header…

    Ooops.

    My navigation goes like this:

    Parent
    child
    child
    child
    subchild
    subchild
    child

    Right now, when I’m on the subchild page, it’s showing the child siblings, not the subchild siblings. I really need on subchild pages for the subchild siblings to show, but on the child pages to show child siblings. Does that make sense?

    I’m using this code:

    else {
    	$children = wp_list_pages('title_li=&child_of=' . $post->ID . '&echo=0');
    }

    TIA!

Viewing 1 replies (of 1 total)
  • The topic ‘Trouble listing page title and listing children’ is closed to new replies.