Skip to content

Instantly share code, notes, and snippets.

@ramseyp
Created August 20, 2014 03:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramseyp/c1dcbe93f66c3dfefc02 to your computer and use it in GitHub Desktop.
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
<?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