Senior Full Stack Developer
December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

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.