Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

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
You can’t perform that action at this time.