Senior Full Stack Developer
October 2024
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
28293031  

Categories


Woocommerce Limit number of products on search results page

MubashirMubashir

Woocommerce search results page shows 16 products per page in the default, but if you want to increase that limit then add the following code into your theme functions.php file.

In the example below we are showing 30 products per page in the search results

add_filter('pre_get_posts',woocommerce_searchfilter');

function woocommerce_searchfilter($query) {

    if ($query->is_search && !is_admin() ) {
        $query->set('post_type',array('product'));
        $query->set('posts_per_page',30);
    }

return $query;
}

 

Comments 0
There are currently no comments.