Code to list child pages not working
-
I used the example code on the get_page_children function reference to display child pages within a custom page template. This worked fine while the site was on my development server, but as soon as it went live it stopped working.
$my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query(array('post_type' => 'page')); $portfolio = get_page_by_path('portfolio'); $pch = get_page_children($portfolio->ID, $all_wp_pages);The problem appears to be the second line, it’s not grabbing all the pages in the database (yes, they are there), instead it’s only getting the newest page.
Being a bit of a newbie at using WordPress, I’m a little bit stumped as to what to do. How can this be fixed, or is there some other code snippet I can use to get the children of a page returned as objects?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Code to list child pages not working’ is closed to new replies.