Last active
June 1, 2020 14:23
-
-
Save stefaeva/954288067dc693f15cd2b09650e8d950 to your computer and use it in GitHub Desktop.
Woocommerce - show product variations without product parent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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