Skip to content

Instantly share code, notes, and snippets.

@moskalukigor
Created October 19, 2018 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moskalukigor/4b0fda8bd02de3f140a54a11ca2aa515 to your computer and use it in GitHub Desktop.
Save moskalukigor/4b0fda8bd02de3f140a54a11ca2aa515 to your computer and use it in GitHub Desktop.
View All without pagination Shop Products Woocommerce
<?php
remove_action('woocommerce_after_shop_loop', 'woocommerce_pagination', 10);
add_action('woocommerce_after_shop_loop', 'customPagination');
function customPagination()
{
if($_GET['view'] != 'all'){
echo '<div class="product-view-all"><a href="?view=all">View All</a></div>';
}
}
add_filter('woocommerce_product_query', 'wg_view_all_products');
function wg_view_all_products($q){
if ( $q->get( 'wc_query' ) === 'product_query' ) {
if($_GET['view'] == 'all'){
$q->set( 'posts_per_page', '-1' );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment