Skip to content

Instantly share code, notes, and snippets.

@vajrasar
Created March 14, 2016 11:47
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 vajrasar/359fbb4a89e68f1bd1d5 to your computer and use it in GitHub Desktop.
Save vajrasar/359fbb4a89e68f1bd1d5 to your computer and use it in GitHub Desktop.
A short snippet for use in stack exchange (wordpress).
<?php //remove this
function loop_p_arch_infinite_scroll_render() {
$paged = get_query_var( 'paged', 1 );
?>
<div id="page-<?=$paged?>">
<?php while( have_posts() ) {
the_post();
get_template_part( 'content', 'product' );
}
?>
</div>
<script id="script-page-<?=$paged?>">
jQuery('document').ready(function() {
var new_elements = jQuery('#page-<?=$paged?>').children('.grid-item');
jQuery('.grid')
.isotope('appended', new_elements)
.imagesLoaded( function() {
jQuery('.grid').isotope('layout');
});
jQuery('.grid').append(new_elements);
jQuery('#page-<?=$paged?>, #script-page-<?=$paged?>').remove();
});
</script>
<?php
}
@ztudeny
Copy link

ztudeny commented Apr 10, 2016

Thanks for the code, it`s great. Just sometimes images does not load properly to isotope and I am getting error "Uncaught TypeError: jQuery(...).isotope(...).imagesLoaded is not a function". Any idea how to fix this?
Thanks a lot and have a great day :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment