Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- - enabled option to show PAST auctions
- - prevent showing PAST auctions unless you are on the shop page
- - useful for shortcodes or widgets to prevent displaying ended auctions if option to show PAST auctions is enabled
- - code snippet should go to your custom plugin or functions.php file
- code by Magnus
- */
- add_filter( 'woocommerce_product_query_meta_query', 'show_only_products_with_specific_metakey', 10, 2 );
- function show_only_products_with_specific_metakey( $meta_query, $query ) {
- // Only on shop pages
- if( ! is_shop() ) return $meta_query;
- $meta_query[] = array(
- 'key' => '_auction_closed',
- 'compare' => 'NOT EXISTS'
- );
- return $meta_query;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement