• Hi I have used the code from http://wordpress.org/support/topic/wp_list_pages-parent-and-children-pages to list the child pages and parent page in a submenu, when there are child or sibling pages to list:

    <?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) { ?>
    				 <div class="submenu">
    
    					<ul>
    					 <?php wp_list_pages( array('title_li'=>'','include'=>get_post_top_ancestor_id()) ); ?>
    					 <?php wp_list_pages( array('title_li'=>'','depth'=>1,'child_of'=>get_post_top_ancestor_id()) ); ?>
    
    					</ul>
    				</div>
    
    			<?php } ?>

    What I would like to do is display entirely different content in its place when there are no child pages:

    <div class="page-title">
    		<div class="page-title-table">
    			<div class="page-title-cell">
    				<?php the_subtitle(); ?>
    			</div>
    		</div>
    	</div>

    I wonder if the code can be modifed for me to do this?

Viewing 1 replies (of 1 total)
  • Have you tried adding another else statement?

    <?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) { ?>
    	 <div class="submenu">
    
    		<ul>
    		 <?php wp_list_pages( array('title_li'=>'','include'=>get_post_top_ancestor_id()) ); ?>
    		 <?php wp_list_pages( array('title_li'=>'','depth'=>1,'child_of'=>get_post_top_ancestor_id()) ); ?>
    
    		</ul>
    	</div>
    <?php } else {
    	// YOUR NEW CODE HERE
    } ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Continuing from '[resolved] wp_list_pages Parent AND Children Pages (10 posts)'’ is closed to new replies.