Senior Full Stack Developer
May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

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.