Work together with Search Everything
-
Hey,
I will also post this here, since it is your plugin I have changed for what I wanted to realize.
First, thanks for your plugin. The interface is so simple yet exactly what I was looking for, and very snappy.
My problem was, I rely heavily on custom fields. Thus, I use the plugin “Search Everything” to replace the original wordpress search. However, at one point where you use WP_Query the original, weaker search is used again. I bypassed the problem by copying a passage from that other plugin into yours, adapting it slightly.
Maybe you have an idea how there two plugins can work together without such a form of modification.
Thank you!
public function ajax_response() { check_ajax_referer( $this->textdomain ); $s = trim( stripslashes( $_GET['q'] ) ); $query_args = apply_filters( 'wpss_search_query_args', array( 's' => $s, 'post_status' => 'publish', ), $s ); // The modified part starts $is_query = !empty($s); $result = array(); if ($is_query) { $result = array( 'own' => array(), 'external' => array() ); $params = array( 's' => $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); $results = array(); if ( $post_query->posts ) { $results = apply_filters( 'wpss_search_results', wp_list_pluck( $post_query->posts, 'post_title' ), $post_query ); echo join( $results, "\n" ); } } wp_die(); // Your original again, though inactive after wp_die() $query = new WP_Query( $query_args ); if ( $query->posts ) { $results = apply_filters( 'wpss_search_results', wp_list_pluck( $query->posts, 'post_title' ), $query ); echo join( $results, "\n" ); } wp_die(); }
- The topic ‘Work together with Search Everything’ is closed to new replies.