Exclude add-to-cart param from get_pagenum_link function. paginate_links calls this function even though we pass a base url to it.

This commit is contained in:
Gerhard Potgieter 2017-11-29 10:52:55 +02:00
parent 7b74dc2576
commit f1479b07d5
1 changed files with 11 additions and 0 deletions

View File

@ -42,6 +42,7 @@ class WC_Query {
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) ); add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
add_action( 'wp', array( $this, 'remove_product_query' ) ); add_action( 'wp', array( $this, 'remove_product_query' ) );
add_action( 'wp', array( $this, 'remove_ordering_args' ) ); add_action( 'wp', array( $this, 'remove_ordering_args' ) );
add_filter( 'get_pagenum_link', array( $this, 'remove_add_to_cart_pagination' ), 10, 1 );
} }
$this->init_query_vars(); $this->init_query_vars();
} }
@ -840,4 +841,14 @@ class WC_Query {
public function layered_nav_query( $deprecated ) { public function layered_nav_query( $deprecated ) {
wc_deprecated_function( 'layered_nav_query', '2.6' ); wc_deprecated_function( 'layered_nav_query', '2.6' );
} }
/**
* Remove the add-to-cart param from pagination urls.
*
* @param string $url URL.
* @return string
*/
public function remove_add_to_cart_pagination( $url ) {
return remove_query_arg( 'add-to-cart', $url );
}
} }