Optimizing large stores – removing product sorting options

In large and very large stores there is a so-called scale effect – loading some pages that generate a heavy load on the database can significantly slow down, while slowing down the entire store. The slow down of the entire store may be caused by resources being blocked by processes that last for a long time. Such operations include, for example, sorting the list of products according to data stored in external database tables (eg wp_postmeta). It is, among others sorting at price, popularity or ratings. Very often these are sorting options not used by customers in the store, but because in large stores, with a large number of products there are many such subpages, a very heavy load is generated by search engines indexing these subpages, e.g. Google.

To disable these pages and when trying to reference them, add the following code in the `functions.php’ file of the theme.


View the code on Gist.

If you do not use the child theme, remember that changes made to the functions.php file will be overwritten when the theme is updated.

While copying code to functions.php file it is not nessesary to copy <?php opening tag.

About grola

Passionate about Wordpress and WooCommerce for many years. Author of plugins and short snippets improving Wordpress and WooCommerce.

View all posts by grola →