Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( ! function_exists( 'gamma_search_query_fix' ) ){
- function gamma_search_query_fix( $query = false ) {
- if(!is_admin() && is_search()){
- $query->set( 'meta_query', array(
- 'relation' => 'OR',
- array(
- 'key' => '_visibility',
- 'value' => 'hidden',
- 'compare' => 'NOT EXISTS',
- ),
- array(
- 'key' => '_visibility',
- 'value' => 'hidden',
- 'compare' => '!=',
- ),
- ));
- }
- }
- }
- add_action( 'pre_get_posts', 'gamma_search_query_fix' );
- // http://www.gammafx.com/woocommerce-hidden-products-in-wordpress-search-results/
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement