Hey Ganubis,
Please try adding following code to Functions.php file in Appearance > Editor
add_action( 'pre_get_posts', 'custom_pre_get_posts_query' );
function custom_pre_get_posts_query( $q ) {
if ( ! $q->is_main_query() ) return;
if ( ! $q->is_post_type_archive() ) return;
if ( ! is_admin() ) {
$q->set( 'meta_query', array(array(
'key' => '_stock_status',
'value' => 'outofstock',
'compare' => 'NOT IN'
)));
}
remove_action( 'pre_get_posts', 'custom_pre_get_posts_query' );
}
Best regards,
Yigit
Thanks Yigit!
It has not worked for me. any other idea? thank you very much :)
Hey!
Please go to WooCommerce > Settings > Products > Inventory and check “Hide out of stock items from the catalog” :)
Regards,
Yigit
Thanks Yigit!
I have tried it but it does not work for me, any other ideas please?
Thanks
Hi,
This link should help you: https://docs.woocommerce.com/document/configuring-woocommerce-settings/ – just find by “out of stock” on the page.
Best regards,
John Torvik
Thanks John!
I have tried it (hide out of stock items from catalog) on WooCommerce > Settings > hide out of stock. but it does not work, any other ideas please?
Thanks
Hi Ganubis,
You might want to ask this question at WooCommerce support forum.
If you need further assistance please let us know.
Best regards,
Victoria