Adding infinite scroll to Isotope grid with several post types
-
I have made a grid on my front page with all post types looping through. There’s an
figure
with a corresponding class (.news
,.project
for example) added to eachfigure
. The grid is mixed up with all classes that displays each post-type..news
shows the regularpost
post-type and.project
shows a custom post-type calledprojekt
.The grid is structured using Isotope. I now want the grid to load in new entries as I scroll. How would I do this the easiest way? The example with Masonry (related to the Isotope plugin) only shows how to loop through the default post-type.
Here’s the loop where I want the infinite scroll to happen:
<div class="isotope-container"> <?php query_posts( array('post_type' => array ( 'projekt', 'post', 'instagram', 'medarbetare'))); while (have_posts()) : the_post();?> <!-- begin of loop --> <!-- Project post loop --> <?php if (get_post_type( $post ) == 'projekt') { ?> <figure class="item item-w2 item-h3 project"> <h3>Projekt</h3><br /> <h2><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></h2> <div class="bg-img"> <div class="overlay"></div> <a href="<?php echo get_permalink(); ?>"><?php the_post_thumbnail(); ?></a> </div> </figure> <!-- Regular post loop --> <?php } else if(get_post_type( $post ) == 'post') { ?> <figure class="item item-h2 news"> <h3>Nyhet</h3> <h2><a href="<?php bloginfo('siteurl'); ?>/nyheter/#<?php the_slug();?>"><?php the_title(); ?></a></h2> <h3 class="date"><?php the_time( 'Y-m-d' ); ?></h3> </figure> <!-- Instagram post loop --> <?php } else if(get_post_type( $post ) == 'instagram') { ?> <figure class="item item-h2 instagram"> <h3>Instagram</h3> <div class="bg-img"> <div class="overlay"></div> <?php the_content(); ?> </div> </figure> <!-- Medarbetare post loop --> <?php } else if(get_post_type( $post ) == 'medarbetare') { ?> <figure class="item item-h2 about"> <h3><a href="<?php bloginfo('template_directory'); ?>/om-oss"><?php the_title(); ?></a></h3> <div class="bg-img"> <div class="overlay"></div> <img class="portrait" src="<?php the_post_thumbnail_url(); ?>" /> </div> </figure> <?php } ?> <?php endwhile; wp_reset_query(); ?> <!-- END of loop --> </div>
Am I missing something?
- The topic ‘Adding infinite scroll to Isotope grid with several post types’ is closed to new replies.