Created
November 14, 2017 09:01
-
-
Save tlehtimaki/768a02cb1b3b65fbb73a554b600716f4 to your computer and use it in GitHub Desktop.
Get wordpress page children ID's
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
<?php | |
// Setup $post | |
glopal $post; | |
// Store current post ID | |
$current_post_id = $post->ID; | |
// Note the slash here refers to global namespace. | |
$children = new \WP_Query( | |
array( | |
'post_type' => 'page', | |
'post_parent' => $current_post_id, | |
'fields' => 'ids' | |
) | |
); | |
array_unshift($children->posts,"{$current_post_id}"); | |
$children_id_arr = $children->posts; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment