Last active
August 29, 2015 14:07
-
-
Save kristianb21/93f77d84247d9a06ef0e to your computer and use it in GitHub Desktop.
PHP:WP-get children
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 | |
//get_children() | |
$args = array( | |
// number of post to retrieve | |
'numberposts' => -1, | |
/* | |
Pass the ID of a post or Page to get its children. | |
Pass 0 to get attachments without parent. | |
Pass null to get any child regardless of parent. | |
*/ | |
'post_parent' => $post->ID, | |
/* | |
Any value from post_type column of the posts table, | |
such as attachment, page, or revision; or the keyword | |
*/ | |
'post_type' => 'any', | |
/* | |
Any value from the post_status column of the wp_posts table, | |
such as publish, draft, or inherit; or the keyword any. | |
*/ | |
'posts_per_page' => -1, | |
'post_status' => 'any', | |
'output' => OBJECT | |
/* | |
Variable type of the array items returned by the function: one of OBJECT, ARRAY_A, ARRAY_N. | |
Default: OBJECT | |
*/ | |
); | |
$output = OBJECT; | |
$children_array = get_children( $args, $output );?> | |
<pre><?php print_r($children_array);?></pre> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment