Skip to content

Instantly share code, notes, and snippets.

@rayflores
Created December 3, 2018 05:35
Show Gist options
  • Save rayflores/826d00cdd3e619de8d5c5945bfa81ff1 to your computer and use it in GitHub Desktop.
Save rayflores/826d00cdd3e619de8d5c5945bfa81ff1 to your computer and use it in GitHub Desktop.
Divi shop module - remove products without product images
<?php
# from Divi shop module Shop.php
# $toggle_filter( 'woocommerce_shortcode_products_query', array( $this, 'shortcode_products_query_cb' ), 10 );
# from WC class-wc-shortcode-products.php
# $query_args = apply_filters( 'woocommerce_shortcode_products_query', $query_args, $this->attributes, $this->type );
# $query_args['meta_query'] = WC()->query->get_meta_query();
add_filter( 'woocommerce_shortcode_products_query', 'remove_if_no_thumbnail', 20, 3);
function remove_if_no_thumbnail( $query_args, $attributes, $type ){
$query_args['meta_query'] = array(
array (
'key' => '_thumbnail_id'
)
);
return $query_args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment