Skip to content

Instantly share code, notes, and snippets.

@Stefaan5
Created July 12, 2016 14:57
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 Stefaan5/67ddc74a0836ce324353b734b53cf9ea to your computer and use it in GitHub Desktop.
Save Stefaan5/67ddc74a0836ce324353b734b53cf9ea to your computer and use it in GitHub Desktop.
I am trying to create a paginated loop of testimonials including the title, featured image, excerpt and permalink to the single page. This is a Custom Post Type made with the plugins CPT UI & ACF. Also, the site is made on a local development environment using MAMP. I was able to create the paginated loop using the snippet from Bill Erickson, wh…
//Create Paginated loop for CPT 'getuigenissen'
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action('genesis_loop', 'getuigenissen_loop');
function getuigenissen_loop(){
$args = array(
'posts_per_page' => 1,
'post_type' => 'getuigenissen',
'order' => 'DESC',
'order_by' => 'menu_order',
'paged' => get_query_var( 'page' )
);
global $wp_query;
$wp_query = new WP_Query( $args );
if ( have_posts() ) :
echo '<div id="getuigenissen-container">';
while ( have_posts() ) : the_post();
?>
<h2><?php the_title(); ?><span> - <?php the_field('adres'); ?></span></h2>
<div class="getuige-imgContainer">
<div class="getuigenisImg" style="background-image: url(<?php the_post_thumbnail_url(); ?>);"></div>
<div class="gallery getuigenisGal">
<?php
$galimgarr = [ get_field('extra_foto_01'), get_field('extra_foto_02'), get_field('extra_foto_03'), get_field('extra_foto_04') ];
foreach ( $galimgarr as $galimage){
if( !empty ($galimage) ){
echo '<div class="extra_foto" style="background-image: url('. $galimage .');"><a href="'. $galimage .'"></a></div>';
}
}
?>
</div>
</div>
<div class="getuigenis-content"><?php the_excerpt(); ?></div>
<!-- Add Link to single getuigenis -->
<a href="<?php the_permalink(); ?>"><p>Lees Meer</p></a>
<hr>
<?php endwhile;
echo '</div>';
do_action( 'genesis_after_endwhile' );
endif;
wp_reset_query();
}
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment