mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://stackoverflow.com/questions/77926151/hide-all-on-sale-products-on-woocommerce-archive-pages
7 lines
338 B
Text
7 lines
338 B
Text
add_action( 'woocommerce_product_query', 'not_on_sale_products_product_query' );
|
|
function not_on_sale_products_product_query( $q ) {
|
|
// On product archive pages only
|
|
if ( is_shop() || is_product_category() || is_product_tag() ) {
|
|
$q->set( 'post__not_in', array_merge( array( 0 ), wc_get_product_ids_on_sale() ) );
|
|
}
|
|
}
|