Trouble listing page title and listing children
-
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)
Viewing 1 replies (of 1 total)
- The topic ‘Trouble listing page title and listing children’ is closed to new replies.