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.
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;
}
}
Got it working. Here’s how: