function st_vc_all_post_type_content_search($attr, $content = false) { $default = array('st_style' => 1, 'st_number' => 5); $attr = wp_parse_args($attr, $default); extract($attr); if (!is_page_template('template-search-all-post-type.php')) { return ""; } $html = ''; global $wp_query, $st_search_query; $data_post_type = STInput::request('data_post_type', 'all'); if ($data_post_type == 'all') { $data_post_type = array('st_hotel', 'st_rental', 'st_cars', 'st_tours', 'st_holidays', 'st_activity'); } else { $data_post_type = array($data_post_type); } /////////////////////////////// ////// Hotel ////////////////////////////// if (st_check_service_available('st_hotel') and in_array('st_hotel', $data_post_type)) { $hotel = new STHotel(); add_action('pre_get_posts', array($hotel, 'change_search_hotel_arg')); query_posts(array('post_type' => 'st_hotel', 's' => '', 'paged' => get_query_var('paged'), 'posts_per_page' => $st_number)); $st_search_query = $wp_query; $html .= st()->load_template('search/search-all-post-type/content', 'all-post-type', array('attr' => $attr)); $html .= '<br>'; remove_action('pre_get_posts', array($hotel, 'change_search_hotel_arg')); $hotel->remove_alter_search_query(); wp_reset_query(); } /////////////////////////////// ////// Rental ////////////////////////////// if (st_check_service_available('st_rental') and in_array('st_rental', $data_post_type)) { $rental = new STRental(); add_action('pre_get_posts', array($rental, 'change_search_arg')); query_posts(array('post_type' => 'st_rental', 's' => '', 'paged' => get_query_var('paged'), 'posts_per_page' => $st_number)); $st_search_query = $wp_query; $html .= st()->load_template('search/search-all-post-type/content', 'all-post-type', array('attr' => $attr)); $html .= '<br>'; remove_action('pre_get_posts', array($rental, 'change_search_arg')); $rental->remove_alter_search_query(); wp_reset_query(); } /////////////////////////////// ////// Activity ////////////////////////////// if (st_check_service_available('st_activity') and in_array('st_activity', $data_post_type)) { $activity = new STActivity(); add_action('pre_get_posts', array($activity, 'change_search_activity_arg')); query_posts(array('post_type' => 'st_activity', 's' => '', 'paged' => get_query_var('paged'), 'posts_per_page' => $st_number)); $st_search_query = $wp_query; $html .= st()->load_template('search/search-all-post-type/content', 'all-post-type', array('attr' => $attr)); $html .= '<br>'; remove_action('pre_get_posts', array($activity, 'change_search_activity_arg')); $activity->remove_alter_search_query(); wp_reset_query(); } /////////////////////////////// ////// Cars ////////////////////////////// if (st_check_service_available('st_cars') and in_array('st_cars', $data_post_type)) { $cars = new STCars(); add_action('pre_get_posts', array($cars, 'change_search_cars_arg')); query_posts(array('post_type' => 'st_cars', 's' => '', 'paged' => get_query_var('paged'), 'posts_per_page' => $st_number)); $st_search_query = $wp_query; $html .= st()->load_template('search/search-all-post-type/content', 'all-post-type', array('attr' => $attr)); $html .= '<br>'; remove_action('pre_get_posts', array($cars, 'change_search_cars_arg')); $cars->remove_alter_search_query(); wp_reset_query(); } /////////////////////////////// ////// Tours ////////////////////////////// if (st_check_service_available('st_tours') and in_array('st_tours', $data_post_type)) { $tours = new STTour(); $tours->alter_search_query(); add_action('pre_get_posts', array($tours, 'change_search_tour_arg')); query_posts(array('post_type' => 'st_tours', 's' => '', 'paged' => get_query_var('paged'), 'posts_per_page' => $st_number)); $st_search_query = $wp_query; $html .= st()->load_template('search/search-all-post-type/content', 'all-post-type', array('attr' => $attr)); $html .= '<br>'; $tours->remove_alter_search_query(); wp_reset_query(); } /////////////////////////////// ////// Holidays ////////////////////////////// if (st_check_service_available('st_holidays') and in_array('st_holidays', $data_post_type)) { $holidays = new STHoliday(); $holidays->alter_search_query(); add_action('pre_get_posts', array($holidays, 'change_search_holiday_arg')); query_posts(array('post_type' => 'st_holidays', 's' => '', 'paged' => get_query_var('paged'), 'posts_per_page' => $st_number)); $st_search_query = $wp_query; $html .= st()->load_template('search/search-all-post-type/content', 'all-post-type', array('attr' => $attr)); $html .= '<br>'; $holidays->remove_alter_search_query(); wp_reset_query(); } return $html; }