Using Masonry/Isotope and Infinite Scroll with Genesis

<?php
/**
* Enqueue Scripts
*
*/
function be_enqueue_blog_scripts() {
wp_enqueue_script( 'be-blog' );
}
add_action( 'wp_enqueue_scripts', 'be_enqueue_blog_scripts', 20 );
view raw archive.php hosted with ❤ by GitHub
jQuery(function($){
// Isotope on load
var $container = $('.content').imagesLoaded( function(){
$container.isotope({
itemSelector: '.entry',
layout: 'masonry',
});
});
// Infinite scroll
$container.infinitescroll({
navSelector: '.archive-pagination', // selector for the paged navigation
nextSelector: '.pagination-next a', // selector for the NEXT link (to page 2)
itemSelector: '.entry', // selector for all items you'll retrieve
loading: {
finishedMsg: 'No more posts to load.',
img: ''
}
},
// call Isotope as a callback
function(newElements) {
var $newElems = jQuery(newElements);
$newElems.imagesLoaded(function() {
$container.isotope('appended', $newElems);
});
}
);
});
view raw blog.js hosted with ❤ by GitHub
<?php
/**
* Register Scripts
*
*/
function be_register_scripts() {
wp_register_script( 'isotope', get_stylesheet_directory_uri() . '/js/isotope.pkdg.min.js', array( 'jquery' ), '2.0.1', true );
wp_register_script( 'imagesloaded', get_stylesheet_directory_uri() . '/js/imagesloaded.pkdg.min.js', array( 'jquery' ), '3.1.8', true );
wp_register_script( 'infinitescroll', get_stylesheet_directory_uri() . '/js/infinitescroll.pkdg.min.js', array( 'jquery' ), '2.0.2', true );
wp_register_script( 'be-blog', get_stylesheet_directory_uri() . '/js/blog.js', array( 'jquery', 'infinitescroll', 'imagesloaded', 'isotope' ), '1.0', true );
}
add_action( 'wp_enqueue_scripts', 'be_register_scripts' );
view raw functions.php hosted with ❤ by GitHub

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk