Created
October 19, 2018 12:14
-
-
Save moskalukigor/4b0fda8bd02de3f140a54a11ca2aa515 to your computer and use it in GitHub Desktop.
View All without pagination Shop Products Woocommerce
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 | |
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