Created
August 4, 2014 02:44
-
-
Save brycejacobson/b3dd8c9c53dfc3299128 to your computer and use it in GitHub Desktop.
Sermon Single 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 $level = count(get_post_ancestors( $post->ID )) + 1; // Finding out if we are on a child post | |
$postid = get_the_ID(); // Getting the id of the current post to find the post_parent below | |
switch($level) { | |
case 1: | |
// WP_Query arguments | |
$args = array ( | |
'post_type' => 'sermon', | |
'posts_per_page' => -1, | |
'post_parent' => $postid, | |
'post_status' => 'publish', | |
'order' => 'ASC' | |
); | |
// The Query | |
$query = new WP_Query( $args ); | |
// The Loop | |
if ( $query->have_posts() ) { | |
while ( $query->have_posts() ) { | |
$query->the_post(); | |
get_template_part( 'content', 'sermons' ); | |
} | |
} else { | |
// no posts found | |
} | |
// Restore original Post Data | |
wp_reset_postdata(); | |
break; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment