Created
April 27, 2017 17:42
-
-
Save WillBrubaker/b6971d0d77f8c5b0738d181ade7ef448 to your computer and use it in GitHub Desktop.
Display WooCommerce Photography Products in Shop
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 characters
| add_action( 'pre_get_posts', 'handsome_bearded_guy_show_photograhpy_products', 99 ); | |
| function handsome_bearded_guy_show_photograhpy_products( $query ) { | |
| if ( ! $query->is_main_query() || is_admin() ) { | |
| return; | |
| } | |
| if ( isset( $query->query_vars['tax_query'] ) && is_post_type_archive( 'product' ) || ( is_page() && isset( $query->query_vars['page_id'] ) && wc_get_page_id( 'shop' ) == $query->query_vars['page_id'] ) && ! is_search() ) { | |
| foreach ( $query->query_vars['tax_query'] as $key => $arr ) { | |
| if ( in_array( 'photography', $arr['terms'] ) ) { | |
| unset( $query->query_vars['tax_query'][ $key ] ); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment