Hi, I’m looking for an infinite scrooling wordpress plugin. At the end of the page, I would like the new posts to load automaticly..
I’ll look at that. Thank you!
/**
* Load javascripts used by the theme
*/
function custom_theme_js(){
wp_register_script( 'infinite_scroll', get_template_directory_uri() . '/js/jquery.infinitescroll.min.js', array('jquery'),null,true );
if( ! is_singular() ) {
wp_enqueue_script('infinite_scroll');
}
}
add_action('wp_enqueue_scripts', 'custom_theme_js');
/**
* Infinite Scroll
*/
function custom_infinite_scroll_js() {
if( ! is_singular() ) { ?>
<script>
var infinite_scroll = {
loading: {
img: "<?php echo get_template_directory_uri(); ?>/images/ajax-loader.gif",
msgText: "<?php _e( 'Loading the next set of posts...', 'custom' ); ?>",
finishedMsg: "<?php _e( 'All posts loaded.', 'custom' ); ?>"
},
"nextSelector":"#post-navigation .next a",
"navSelector":"#post-navigation",
"itemSelector":"article",
"contentSelector":"#primary"
};
jQuery( infinite_scroll.contentSelector ).infinitescroll( infinite_scroll );
</script>
<?php
}
}
add_action( 'wp_footer', 'custom_infinite_scroll_js',100 );
But it doesn’t work. Are my selectros correct according to my template?
dont know what theme you are using, but you need to have the same selctors as in the code
It’s the pixelpower theme. And, I’m not sure to understand what is a “selector” (the div id or class?)
nextSelector .next a”,
so your next link has to have that or it wont do anything.
