Skip to content

Instantly share code, notes, and snippets.

@billerickson

billerickson/archive.php Secret

Created Oct 30, 2014
Embed
What would you like to do?
<?php
/**
* Enqueue Scripts
*
*/
function be_enqueue_blog_scripts() {
wp_enqueue_script( 'be-blog' );
}
add_action( 'wp_enqueue_scripts', 'be_enqueue_blog_scripts', 20 );
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);
});
}
);
});
<?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' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.