function search_everything_callback() { $is_query = !empty($_GET['s']); $result = array(); if ($is_query) { $result = array('own' => array(), 'external' => array()); $params = array('s' => $_GET['s']); $zemanta_response = se_api(array('method' => 'zemanta.suggest', 'return_images' => 0, 'return_rich_objects' => 0, 'return_articles' => 1, 'return_markup' => 0, 'return_rdf_links' => 0, 'return_keywords' => 0, 'careful_pc' => 1, 'interface' => 'wordpress-se', 'format' => 'json', 'emphasis' => $_GET['s'], 'text' => $_GET['text'])); if (!is_wp_error($zemanta_response) && $zemanta_response['response']['code'] == 200) { $result['external'] = json_decode($zemanta_response['body'])->articles; } $SE = new SearchEverything(true); if (!empty($_GET['exact'])) { $params['exact'] = true; } $params["showposts"] = 5; $post_query = new WP_query($params); while ($post_query->have_posts()) { $post_query->the_post(); $result['own'][] = get_post(); } $post_query->reset_postdata(); } print json_encode($result); die; }