Created
September 16, 2013 22:49
-
-
Save austinpray/6587660 to your computer and use it in GitHub Desktop.
Wordpress get children of current page and list them by menu order. EG to get locations of a locations page. Put me in a page template
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 | |
$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
Nice one