Skip to content

Instantly share code, notes, and snippets.

@brycejacobson
Created August 4, 2014 02:44
Show Gist options
  • Save brycejacobson/b3dd8c9c53dfc3299128 to your computer and use it in GitHub Desktop.
Save brycejacobson/b3dd8c9c53dfc3299128 to your computer and use it in GitHub Desktop.
Sermon Single Page
<?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