Created
August 13, 2014 20:23
-
-
Save drrobotnik/049855d681b2cf986750 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Add theme support for infinite scroll. | |
* | |
* @uses add_theme_support | |
* @return void | |
*/ | |
function gh_infinite_scroll_init() { | |
add_theme_support( 'infinite-scroll', array( | |
'container' => 'isoblock', | |
'wrapper' => false, | |
'render' => 'gh_isotope' | |
) ); | |
} | |
add_action( 'after_setup_theme', 'gh_infinite_scroll_init' ); | |
function gh_isotope(){ | |
$html = ''; | |
$loop_count = 0; | |
while ( have_posts() ) : the_post(); | |
global $post; | |
$loop_count++; | |
$post->loop_count = $loop_count; | |
the_post(); | |
$html .= load_template_part( 'content', get_post_format() ); | |
endwhile; | |
$html = wp_kses_post( $html ); | |
?> | |
<script type="text/javascript"> | |
( function( $ ) { | |
var $container = $('#isoblock'); | |
$items = <?php echo $html; ?>; | |
console.log($items); | |
$container.isotope( 'appended', $items ); | |
} )( jQuery ); | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment