Created
November 9, 2014 21:26
-
-
Save x1024/3a7fcc13300116c35583 to your computer and use it in GitHub Desktop.
WP Grandchildren
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
the_post(); | |
$children = new WP_Query( array('post_type' => 'page', 'post_parent' => get_the_ID() ); | |
$ids = array(); | |
if ($children->have_posts()) { | |
while ($children->have_posts()) { | |
$children->the_post(); | |
array_push($ids, get_the_id()); | |
} | |
} | |
foreach ($ids as $id) { | |
$grandchildren = new WP_Query( array('post_type' => 'page', 'post_parent' => $id ); | |
while ($grandchildren->have_posts()) { | |
$grandchildren->the_post(); | |
the_title(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment