• Resolved csleh

    (@csleh)


    I”m using this in the loop of a page template

    <article class="eight columns">
          	<?php the_content(); ?>
    	</article>
    	<aside>
    	<?php wp_list_pages('title_li=');  ?>
    	</aside>

    as expected, this lists all pages and subpages in the site.
    this does not work and nothing is shown:

    <?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 } ?>

    nor does similar code used to modify wp_list_pages to get only the parent and siblings of the current page.
    Am I missing something very simple here?

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

    (@csleh)

    wait, it started working but without showing the parent. this bit of messy code shows the parent as a heading then lists children

    <?php $parent = get_the_title($post->post_parent);
    	if  (is_page() && $post->post_parent ) { ?>
    <h4><a href="<?php echo get_permalink($post->post_parent) ?>"><?php echo $parent;?></a></h4>
    		<?php } ?>
    <?php if($post->post_parent)
      $children = wp_list_pages("title_li=&child_of=".$post->post_parent."");
      if ($children) { ?>
      <ul><?php echo $children; ?></ul>
      <?php } ?>

Viewing 1 replies (of 1 total)
  • The topic ‘wp_list_pages works but adding child pages doesn't’ is closed to new replies.