I'm using Wordpress and manually adding Infinte Scroll from paulirish on GitHub: https://github.com/paulirish/infinite-scroll/

It loads properly, but how can I add a wrapper around all my posts?

Essentially, I'm outputting each post within a <li> tag. And I want to add an <ol> to surround/wrap the list item of posts. Any thoughts how to do so?

For Reference, this is the script I'm using in the functions.php file:

 * Load Javascript for Infinte Scroll
function custom_theme_js(){
    wp_register_script( 'infinite_scroll',  get_template_directory_uri() . '/js/jquery.infinitescroll.min.js', array('jquery'),null,true );
    if( ! is_page_template( 'archive' ) ) {
add_action('wp_enqueue_scripts', 'custom_theme_js');

 * Infinite Scroll
function custom_infinite_scroll_js() {
    if( ! is_page_template( 'archive' ) ) { ?>
    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":".navigation .nav-next a",
    jQuery( infinite_scroll.contentSelector ).infinitescroll( infinite_scroll );
add_action( 'wp_footer', 'custom_infinite_scroll_js',100 );


1 Answer 1


You would control the markup by editing archive.php. Here you can add a wrapper to individual posts.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.