ID) { return; } $term = mysql_escape_string($_GET['term']); $category = get_category(get_option('gallery_post_category')); if ($category) { $sql = " SELECT p.ID, p.post_title FROM " . $wpdb->prefix . "posts AS p INNER JOIN " . $wpdb->prefix . "term_relationships AS tr ON (p.ID = tr.object_id) WHERE 1=1 AND ( tr.term_taxonomy_id = " . $category->term_taxonomy_id . ") AND p.post_type = 'post' AND (p.post_status = 'publish') AND (p.post_title LIKE '%" . $term . "%') GROUP BY p.ID ORDER BY p.post_date DESC LIMIT 25"; $posts = $wpdb->get_results($sql, ARRAY_A); $results = array(); foreach ($posts as $p) { $row = array('id' => $p['ID'], 'label' => $p['post_title'], 'value' => $p['post_title']); array_push($results, $row); } print json_encode($results); } } ?>