How can I display only my free WooCommerce products on a page?

These products change each week, and I want a page that displays my current free products without having to update these products manually on this page each week. I believe it needs to search for only product sale prices that equal 0, or free.


You should be able to create a category and call that category via shortcode on the page of your choice.

array( 'per_page' => '12',     'columns' => '4',       'orderby' => 'title',       'order' => 'asc',       'category' => '' )

[product_category category="appliances"]

  • Yes I like this and is a workaround. But I offer free products for a week at a time and I use the schedule to do this so I don't have to go back and edit each week. I may forget or be too busy. That is why I prefer to have the page list free items by the price instead. – d3vo Nov 8 '15 at 0:56

You can do something like this to get the product ids, and then display them:

// create a query string for checking that any of the three
// basic ways of storing the price is '0'
$query_string = 'SELECT post_id FROM ' . $wpdb -> prefix . 'postmeta WHERE ( meta_key = %s OR meta_key = %s OR meta_key = %s ) AND meta_value = "0"';

// Query the database
$free_products = $wpdb -> get_col( $wpdb -> prepare( $query_string, '_price', '_regular_price', '_sale_price' ));

// only get each id once
$free_products = array_unique( $free_products );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.