Skip to content

Instantly share code, notes, and snippets.

@wpflames
Last active January 22, 2021 17:55
Show Gist options
  • Select an option

  • Save wpflames/d03e7881bf85611be21044618e21e7a9 to your computer and use it in GitHub Desktop.

Select an option

Save wpflames/d03e7881bf85611be21044618e21e7a9 to your computer and use it in GitHub Desktop.
Genesis Loop for Custom Post Type with Pagination
<?php
// =========================================================================
// GENESIS LOOP FOR CUSTOM POST TYPE
// =========================================================================
function custom_loop_with_pagination() {?>
<article class="page type-page entry">
<header class="entry-header">
<h1 class="entry-title"><?php the_title(); ?></h1>
</header>
<?php global $post;
$args = array(
'post_type' => 'YOUR_POST_TYPE',
'posts_per_page' => 10,
'paged' => get_query_var( 'paged' )
);
global $wp_query;
$wp_query = new WP_Query( $args );
if ( have_posts() ) :
while ( have_posts() ) : the_post(); ?>
<!--YOUR CUSTOM CONTENT-->
<h2><?php the_title(); ?></h2>
<?php endwhile;
do_action( 'genesis_after_endwhile' );
endif;
wp_reset_query();
echo '</article>';
}
add_action( 'genesis_loop', 'custom_loop_with_pagination' );
remove_action( 'genesis_loop', 'genesis_do_loop' );
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment