Skip to content

Instantly share code, notes, and snippets.

@mashcom
Created April 19, 2018 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mashcom/6c95f8609f560f3ad5e3b5d7cfb14a55 to your computer and use it in GitHub Desktop.
Save mashcom/6c95f8609f560f3ad5e3b5d7cfb14a55 to your computer and use it in GitHub Desktop.
Get children of a current page
<?php
$id = the_ID();
while ( have_posts() ) : the_post();
$gp_args = array(
'post_type' => 'page',
'post_parent' => $id,
'order' => 'ASC',
'orderby' => 'menu_order',
'posts_per_page' => -1
);
$locations = get_posts($gp_args);
echo '<pre>' . print_r( $locations, true ) . '</pre>';
endwhile;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment