Infinite Scroll – WooCommerce Shop

PHP Code Snippets/Functions

This function will allow you to control the number of products displayed on your Shop page by changing the value of the $cols parameter. Insert the code below in your functions.php file.

add_filter( 'loop_shop_per_page', 'custom_loop_shop_per_page', 20 );

function custom_loop_shop_per_page( $cols ) {
    $cols = 9999;
    return $cols;
}

add_filter( 'woocommerce_pagination_args', 'custom_pagination_args' );

function custom_pagination_args( $args ) {
    $args['prev_next'] = false;

   $args['show_all'] = true;

    return $args;
}
add_action( 'woocommerce_after_shop_loop', 'custom_pagination_div', 5 );

function custom_pagination_div() {
    echo '<div class="custom-pagination-div">';
}

Leave a Reply

Your email address will not be published. Required fields are marked *