A short snippet for use in stack exchange (wordpress).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 :)