-
-
Save aadityajs/8235880 to your computer and use it in GitHub Desktop.
WooCommerce - Change products per page conditionally
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
<?php | |
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;') ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment