# Hide Products Without a Price From the Shop

> Keeps unfinished products that have no price yet out of the shop, category pages and product searches until you add one.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, catalog, visibility, prices
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-hide-products-without-price/

## Code

```php
$wpide_require_price = function ( $query ) {
    $meta_query   = (array) $query->get( 'meta_query' );
    $meta_query[] = array(
        'key'     => '_price',
        'value'   => '',
        'compare' => '!=',
    );
    $query->set( 'meta_query', $meta_query );
};

add_action( 'woocommerce_product_query', $wpide_require_price );

add_filter( 'woocommerce_shortcode_products_query', function ( $args ) {
    $args['meta_query']   = isset( $args['meta_query'] ) ? (array) $args['meta_query'] : array();
    $args['meta_query'][] = array( 'key' => '_price', 'value' => '', 'compare' => '!=' );

    return $args;
} );
```

## Notes

Products stay reachable by direct link, and variable products are listed when any variation has a price.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Hide Products Without a Price From the Shop" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
