Created
August 22, 2016 16:35
-
-
Save sterndata/d737161f540b610a9f0e215572362fb5 to your computer and use it in GitHub Desktop.
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
function lcas_list_children( $atts, $content ) { | |
global $post; | |
ob_start(); | |
$args = array( | |
'post_parent' => $post->ID, | |
'post_type' => 'page', | |
'orderby' => 'title', | |
'order' => 'ASC', | |
); | |
$myquery = new WP_Query( $args ); | |
if ( $myquery->have_posts() ) { | |
while ( $myquery->have_posts() ) { | |
$myquery->the_post(); | |
echo '<h2><a href="' . get_the_permalink() . '">'; | |
the_title(); | |
echo '</a></h2>'; | |
the_excerpt(); | |
} | |
} else { | |
echo 'No pages found'; | |
} | |
wp_reset_query(); | |
return '<div class="child_pages">' . ob_get_clean() . '</div>'; | |
} | |
add_shortcode( 'list_child_pages', 'lcas_list_children' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment