Jump to content

Wordpress ?; Parent and Child Page Display


atticus

Recommended Posts

Hi all,

 

I want my child pages on wordpress to only show when the parent or child page is clicked on.  The problem is that when the parent page is clicked on, wordpress adds the child page under the whole list instead of directly under the parent page. 

 

<h2>Pages</h2>	
<ul>
<?php
wp_list_pages('depth=1&sort_column=menu_order&title_li='); ?> 
<?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 } ?> 
</ul>

Link to comment
https://forums.phpfreaks.com/topic/114062-wordpress-parent-and-child-page-display/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.