Senior Full Stack Developer
April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

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.