Skip to content

Instantly share code, notes, and snippets.

@mikejolley
Created August 15, 2012 09:32
Show Gist options
  • Save mikejolley/3358102 to your computer and use it in GitHub Desktop.
Save mikejolley/3358102 to your computer and use it in GitHub Desktop.
WooCommerce - Change products per page conditionally
add_action( 'pre_get_posts', 'mj_change_per_page' );
function mj_change_per_page() {
if ( is_product_category( 'games' ) ) {
add_filter('loop_shop_per_page', create_function('$cols', 'return 1;') );
} else {
add_filter('loop_shop_per_page', create_function('$cols', 'return 8;') );
}
}
@ConradGalli
Copy link

Hi Mike, there is a way to do this in the front end, with a dropdown?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment