Skip to content

Instantly share code, notes, and snippets.

@stefaeva
Last active June 1, 2020 14:23
Show Gist options
  • Save stefaeva/954288067dc693f15cd2b09650e8d950 to your computer and use it in GitHub Desktop.
Save stefaeva/954288067dc693f15cd2b09650e8d950 to your computer and use it in GitHub Desktop.
Woocommerce - show product variations without product parent
/* i need help to modify this snippet to show only the product variations without the product parent */
add_action( 'pre_get_posts', 'custom_remove_products_from_shop_page' );
function custom_remove_products_from_shop_page( $q ) {
if ( ! $q->is_main_query() ) return;
if ( ! $q->is_post_type_archive() ) return;
if ( ! is_admin() && is_shop() ) {
$q->set( 'post__in', array(0) ); }
remove_action( 'pre_get_posts', 'custom_remove_products_from_shop_page' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment