By default, WooCommerce displays a pagination bar at the bottom of the shop page, which allows users to navigate through the different pages of products. However, some users may want to remove the pagination for various reasons, such as improving page load time, improving user experience, or simply because they prefer infinite scroll.
In this blog post, we will discuss how to remove pagination on the WooCommerce shop page programmatically. We will walk you through the process step-by-step, so even if you have little to no coding experience, you can follow along.
Step 1: Eliminate page navigation
Here’s a little code snippet made by CodexCoach that you can add to your WooCommerce shop to eliminate the usual WooCommerce page navigation from the shop page:
<?php
/**
* Cxc Remove Shop Page Pagination
*/
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 );
?>
Step 2: Remove Pagination Programmatically
In the functions.php file of your child theme, add the following code to remove pagination from the WooCommerce shop page.
<?php
add_filter( 'loop_shop_per_page', 'cxc_shop_loop_per_page_call_back', 20 );
function cxc_shop_loop_per_page_call_back( $cols ) {
// $cols holds the current number of goods per page, as determined by the
// value specified in Options -> Reading.
// Return the number of items to display per page.
$cols = 50;
return $cols;
}
?>
We discussed how to dynamically disable pagination from the WooCommerce shop page. You can quickly remove pagination and improve the user experience of your website by establishing a child theme and adding a few lines of code to the functions.php file.
FAQs
Why would I want to remove pagination from the WooCommerce shop page?
Some users prefer infinite scroll over pagination as it provides a seamless browsing experience without requiring them to click through pages. Additionally, removing pagination may improve page load times and reduce server load.
Will removing pagination affect the SEO of my online store?
No, removing pagination should not have any significant impact on the SEO of your online store. However, it is important to ensure that your product categories and tags are well-organized and optimized for search engines.
Can I remove pagination without creating a child theme?
It is not recommended to remove pagination without creating a child theme. Modifying the original theme files directly could lead to problems when you update the theme in the future.
Wow I found all the solutions in your site for my site. Thank you codexcoach !!