Skip to content

Instantly share code, notes, and snippets.

@nickkuijpers
Last active August 29, 2015 14:20
Show Gist options
  • Save nickkuijpers/f05653ef049f0bd1a5ea to your computer and use it in GitHub Desktop.
Save nickkuijpers/f05653ef049f0bd1a5ea to your computer and use it in GitHub Desktop.
WooCommerce Add Amount Per Page
$value = $_POST['woocommerce-sort-by-columns'];
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return ' . $value . ';' ), 20 );
function woocommerce_catalog_page_ordering($value) {
$amounts = array(
20,
30,
80,
160,
250
);
echo '<form action="" method="post" name="results">';
echo '<select class="woocommerce-sort-by-columns" name="woocommerce-sort-by-columns" onchange="document.forms[\'results\'].submit();">';
foreach($amounts as $amount){
if($amount == $value){
$selected = "SELECTED";
} else {
$selected = "";
}
echo '<option value="' . $amount . '" ' . $selected . '>' . $amount . ' producten</option>';
}
echo '</select>';
echo '</form>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment