Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function advanced_product_search_filter($query)
- {
- if(!is_admin() &&
- is_main_query() &&
- is_search() && $query->query_vars['post_type'] == 'product')
- {
- $keyword = $_GET['s'];
- if($_GET['exactly'])
- $keyword = $_GET['s'] . ' "'. $_GET['exactly'] . '"';
- if($_GET['without'])
- {
- $excluded = exclude_product_keyword_search($_GET['without'],
- $_GET['pname'],
- $_GET['pcode']
- );
- $query->set('post__not_in', $excluded);
- }
- if($_GET['pname'])
- $query->set('s', $keyword);
- else
- $query->set('s', '');
- if($_GET['pcode'])
- {
- $tax_queries = $query->get('tax_query');
- $tax_queries[] = array(
- array(
- 'taxonomy' => 'pa_ordering-code',
- 'field' => 'name',
- 'terms' => array($keyword),
- 'operator' => 'LIKE'
- )
- );
- $query->set('tax_query', $tax_queries);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement