Last active
June 1, 2020 14:23
-
-
Save stefaeva/954288067dc693f15cd2b09650e8d950 to your computer and use it in GitHub Desktop.
Revisions
-
stefaeva revised this gist
Jun 1, 2020 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ /* 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; -
stefaeva created this gist
Jun 1, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ 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' );