Senior Full Stack Developer
November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

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.