Created
October 15, 2014 22:28
-
-
Save daronspence/c3411fd1fc4f4951799b to your computer and use it in GitHub Desktop.
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 | |
$args = array( | |
// Get children of current page | |
'post_parent' => $post->ID, | |
'post_type' => 'page', | |
); | |
$query = new WP_Query($args); | |
if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); | |
$template = get_post_meta( $post->ID, '_wp_page_template', true ); | |
// Template must have 1 dash. EG: "template-name.php" | |
$template = pathinfo($template); | |
$template_parts = explode('-', $template['filename']); | |
// use first 2 keys in array of $template_parts | |
get_template_part( $template_parts[0], $template_parts[1] ); | |
endwhile; endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment