Note: This is a Developer level doc. If you are unfamiliar with code/templates and resolving potential conflicts, select a WooExpert or DeveloperĀ for assistance. We are unable to provide support for customizations under ourĀ Support Policy.
Storefront has a lotĀ of filters (go here for an overview). These allow you to change the output of how things are displayed in the theme.
For example, you could want to change the shop page template to only display 8 products instead of the default 12.
Create a function
ā Back to topalter_sf_products_per_page ()
.Ā Since we want to change the default 12 to 8, that is what we need to add: return 8;
.
Find the right hook
ā Back to topstorefront_products_per_page
.
Add a filter
ā Back to top
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function alter_sf_products_per_page() { | |
// Return the number of products per page ( default: 12 ). | |
return 8; | |
} | |
add_filter('storefront_products_per_page', 'alter_sf_products_per_page' ); |
functions.php
file of your child theme.
The result will be the following: