How to show only child pages of a Sub Child Page in WordPress?

So, I have a page structure in place that kind of looks like this

    Location
    - New York
      - Restaurant #1
        - Dinner Menu
        - Lunch Menu
      - Restaurant #2
        - Dinner Menu
        - Lunch Menu

So when I am lets say the Restaurant #1 page, I want it show all the child pages of Restaurant #1 only. Unfortunately my current code base is returning all the Child pages of New York instead.

Read More

Here’s my code:

if ( is_page() ) {
   if($post->post_parent)
       $children = wp_list_pages('sort_column=menu_order&title_li=&child_of='.$post->post_parent.'&echo=0');
   else
       $children = wp_list_pages('sort_column=menu_order&title_li=&child_of='.$post->ID.'&echo=0');

   if ($children) {
       echo $children; 
   }

}

Related posts

Leave a Reply

1 comment

  1. Got it working. Here’s how:

    <? $pages = get_pages('child_of='.$post->ID.'&sort_column=post_title'); 
    $count = 0; 
    foreach($pages as $page){ ?>
      <li>
        <a href="<? echo get_page_link($page->ID) ?>"><? echo$page->post_title?></a>
      </li>
    <? } 
    ?>