<?php if (get_query_var('shop_category') || themex_search('shop')) { get_template_part('template', 'shops'); } else { get_template_part('template', 'posts'); }
/** * Filters shops query * * @access public * @param mixed $query * @return mixed */ public static function filterShops($query) { if (!is_admin() && $query->is_main_query()) { if ($query->is_tax('shop_category') || themex_search('shop')) { $number = intval(ThemexCore::getOption('shops_per_page', 6)); $query->set('posts_per_page', $number); } if (themex_search('shop')) { $meta = $query->get('meta_query'); //category $category = intval(themex_array('category', $_GET)); if (!empty($category)) { $query->set('tax_query', array(array('taxonomy' => 'shop_category', 'terms' => $category))); } //country $country = sanitize_text_field(themex_array('country', $_GET)); if (!empty($country)) { $meta[] = array('key' => '_' . THEMEX_PREFIX . 'country', 'value' => $country); } //city $city = sanitize_text_field(themex_array('city', $_GET)); if (!empty($city)) { $meta[] = array('key' => '_' . THEMEX_PREFIX . 'city', 'value' => $city); } $query->set('meta_query', $meta); } else { if (themex_search('post')) { $query->set('post_type', 'post'); } } } return $query; }