In my WooCommerce store, I have "Hide out of stock items from the catalogue" enabled. This option causes product variations on individual pages to become invisible.
I want to apply "Hide out of stock items from the catalogue" option only on archive pages (search, categories).
Here is my code:
function featured_posts( $query ) {
if ( ! $query->is_main_query() ) return;
//What goes in here?
}
add_action( 'pre_get_posts', 'featured_posts' );
How can I achieve this?
Thanks