Last active
March 10, 2017 13:20
-
-
Save marcosnakamine/94d46e892efa287e614a77cc3cf3701a to your computer and use it in GitHub Desktop.
WordPress - Get all child of parent page
This file contains hidden or 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 | |
$page_parent = get_page_by_path( 'page-parent-slug' ); // GET PAGE BY SLUG | |
$page_childs = get_pages( array( | |
'parent' => $page_parent->ID //GET CHILDS | |
) ); | |
print_r( $page_childs ); | |
/* | |
Array | |
( | |
[0] => WP_Post Object | |
( | |
[ID] => 975 | |
[post_author] => 1 | |
[post_date] => 2017-02-02 14:22:00 | |
[post_date_gmt] => 2017-02-02 16:22:00 | |
[post_content] => [gallery size="full" ids="976,977,978,979,980,981,982,983,984,985,986"] | |
[post_title] => Title | |
[post_excerpt] => | |
[post_status] => publish | |
[comment_status] => closed | |
[ping_status] => closed | |
[post_password] => | |
[post_name] => title | |
[to_ping] => | |
[pinged] => | |
[post_modified] => 2017-02-02 14:22:00 | |
[post_modified_gmt] => 2017-02-02 16:22:00 | |
[post_content_filtered] => | |
[post_parent] => 548 | |
[guid] => http://site.com/?page_id=975 | |
[menu_order] => 2 | |
[post_type] => page | |
[post_mime_type] => | |
[comment_count] => 0 | |
[filter] => raw | |
) | |
) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment