I’ve been bashing my head against my desk all afternoon trying to figure this out. I’ve got a custom post type all set up, with hierarchical set to “true” and I can assign parents and see the relationship in the back end. Which is great.
Except I want to list the children (and siblings) of my special new post type. I found this code
<?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 } ?>
which works perfectly when I put it into a page template for pages. But it returns squat for the custom post template.
I thought “$post->post_parent)” might be the issue — but it’s not:
<h1 class="page-title"><a href="https://wordpress.stackexchange.com/questions/5058/<?php echo get_permalink($post->post_parent) ?>" title="<?php printf( __( 'Return to %s', 'your-theme' ), wp_specialchars( get_the_title($post->post_parent), 1 ) ) ?>" rev="attachment"><span class="meta-nav">« </span><?php echo get_the_title($post->post_parent) ?></a></h1>
(lifted from an attachment template) does give me a back link to the parent. — so maybe it has something to do with wp_list_pages? Maybe it’s something else? I’d appreciate any ideas.
Thanks in advance,
Martin