$hotel = new Hotel(); $resp = new ajax_response($data['action'], true); if ($data['hotel_type'] != null) { $args = array('post_type' => 'hotel', 'posts_per_page' => '-1', 'orderby' => 'post_title', 'order' => $data['hotel_sort'], 'tax_query' => array(array('taxonomy' => 'hotel-category', 'field' => 'slug', 'terms' => $data['hotel_type']))); } else { $args = array('post_type' => 'hotel', 'posts_per_page' => '-1', 'orderby' => 'post_title', 'order' => $data['hotel_sort']); } $loop = new WP_Query($args); if ($loop->have_posts()) { $resp->set_status(true); $resp->set_data(array('hotels' => $hotel->get_all_hotels($args))); } else { $resp->set_message('No Hotels found. Try again hoss.'); } echo $resp->encode_response(); die; } public function load_hotels_async() { $data = $_POST; $hotel = new Hotel(); $resp = new ajax_response($data['action'], true); $resp->set_status(true); $resp->set_data(array('loadable_content' => $hotel->get_all_hotels($args))); echo $resp->encode_response(); die; } } $hotel = new Hotel(); $hotel->init_actions();