Created
August 20, 2014 03:10
-
-
Save ramseyp/c1dcbe93f66c3dfefc02 to your computer and use it in GitHub Desktop.
Genesis child theme custom page template that shows child pages of the current page. Heavily based on: https://gist.github.com/billerickson/3218052
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 | |
/* | |
Template Name: Custom Loop | |
*/ | |
remove_action( 'genesis_loop','genesis_do_loop' ); | |
add_action( 'genesis_loop','my_custom_loop' ); | |
function my_custom_loop() { | |
global $post; | |
// arguments, adjust as needed | |
$args = array( | |
'post_type' => 'page', | |
'post_parent' => $post->ID, | |
'posts_per_page' => get_option('posts_per_page'), | |
'post_status' => 'publish', | |
'paged' => get_query_var( 'paged' ) | |
); | |
/* | |
Overwrite $wp_query with our new query. | |
The only reason we're doing this is so the pagination functions work, | |
since they use $wp_query. If pagination wasn't an issue, | |
use: https://gist.github.com/3218106 | |
*/ | |
global $wp_query; | |
$wp_query = new WP_Query( $args ); | |
if ( have_posts() ) : | |
while ( have_posts() ) : the_post(); ?> | |
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> | |
<header class="entry-header"><a href="<?php echo esc_url( get_permalink() ); ?>" rel="bookmark"><?php echo get_the_title(); ?></a></header> | |
<div class="entry-content"> | |
<?php do_action( 'genesis_entry_content' ); ?> | |
</div><!-- .entry-content --> | |
<?php do_action( 'genesis_entry_footer' ); ?> | |
</article> | |
<?php | |
endwhile; | |
do_action( 'genesis_after_endwhile' ); | |
endif; | |
wp_reset_query(); | |
} | |
//* Make rocket go fast now | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment