static function dwls_alter_results($wpQueryResults, $maxResults, $results) { global $wp_query; // WP_Query::query() set everything up // Now have Relevanssi do the query over again // but do it in its own way // Thanks Mikko! relevanssi_do_query($wp_query); $results->relevanssi = true; // Mikko says Relevanssi 2.5 doesn't handle limits // when it queries, so I need to handle them on my own. $wpQueryResults = array_slice($wp_query->posts, 0, $maxResults); return $wpQueryResults; }
function relevanssi_query($posts, $query = false) { $admin_search = get_option('relevanssi_admin_search'); $admin_search == 'on' ? $admin_search = true : ($admin_search = false); global $relevanssi_active; global $wp_query; $search_ok = true; // we will search! if (!is_search()) { $search_ok = false; // no, we can't } // Uses $wp_query->is_admin instead of is_admin() to help with Ajax queries that // use 'admin_ajax' hook (which sets is_admin() to true whether it's an admin search // or not. if (is_search() && $wp_query->is_admin) { $search_ok = false; // but if this is an admin search, reconsider if ($admin_search) { $search_ok = true; } // yes, we can search! } if ($wp_query->is_admin && empty($wp_query->query_vars['s'])) { $search_ok = false; } // Disable search in media library search if ($search_ok) { if ($wp_query->query_vars['post_type'] == 'attachment' && $wp_query->query_vars['post_status'] == 'inherit,private') { $search_ok = false; } } $search_ok = apply_filters('relevanssi_search_ok', $search_ok); if ($relevanssi_active) { $search_ok = false; // Relevanssi is already in action } if ($search_ok) { $wp_query = apply_filters('relevanssi_modify_wp_query', $wp_query); $posts = relevanssi_do_query($wp_query); } return $posts; }
function ajax_wp_search() { global $wp_query; global $paged; $query_string = isset($_GET['query']) ? $_GET['query'] : ""; $paged = $_GET['page']; if (isset($_GET['query']) && $query_string != '') { $query_args = array('s' => $query_string, 'post_type' => array('post', 'page'), 'posts_per_page' => 3, 'paged' => $paged); $wp_query = new WP_Query($query_args); $rel_query = relevanssi_do_query($wp_query); if (count($rel_query) > 0) { get_template_part('partials/content', 'normal'); } else { echo "No related content was found"; } } else { echo "Please enter a search term to retrieve related content"; } wp_reset_postdata(); die; }
/** This genarate_ajax_pagination function is used to genarate the pagination button * @param Array WordPress $wp_query variable * @param String Localize the Button name * @param String Button style * @return String HTML pagination Button */ function genarate_ajax_pagination($readMore = 'Read More', $buttonStyle = '', $loop = 'content', $query = array()) { global $wp_query; if (!empty($query)) { //if user give custom query $query = serialized($query, true); $post_query = new WP_Query($query); if ($_GET['s']) { relevanssi_do_query($post_query); } $maxpages = $post_query->max_num_pages; wp_reset_query(); } else { $query = ''; $maxpages = $wp_query->max_num_pages; } //if no 2 pages just return nothing if ($maxpages < 2) { return; } //get the ajax loading animation gif $src_path = WP_PLUGIN_URL . '/ajax-pagination/img/ajax-loader.gif'; $linkHTML = '<div id="ajax-post-container"></div> <div class="more_post"> <a class="btn btn-primary" id="ajax_pagination_btn" href="#" ><span class="_ajax_link_text">' . $readMore . '</span></a> <span class="_ajaxpaging_loading" style="display: none;"><img src="' . $src_path . '" alt="Loading.." /></span> </div>'; $linkHTML .= '<script type="text/javascript">jQuery(function() { jQuery("#ajax_pagination_btn").ajaxpaging({ loop: "' . $loop . '", maxpages: "' . $maxpages . '", query: "' . $query . '" }); }); </script>'; echo $linkHTML; }
function the_results($sfid) { global $sf_form_data; $args = ""; $args = $this->get_query_args($sfid); $returnvar = ""; add_action('posts_where', array($this, 'filter_meta_query_where')); add_action('posts_join', array($this, 'filter_meta_join')); // Attach hook to filter WHERE clause. //add_filter('posts_where', array($this,'limit_date_range_query')); // Remove the filter after it is executed. //add_action('posts_selection', array($this,'remove_limit_date_range_query')); if ($sf_form_data->settings("maintain_state") == 1) { add_filter('the_permalink', array($this, 'maintain_search_settings')); } $query = new WP_Query($args); if ($sf_form_data->settings("force_is_search") == 1) { $query->set('is_search', true); $query->is_search = true; } //if S is set, use Relevanssi //if relevanssi exists & enabled //if user has also ticked to enable relevanssi if ($sf_form_data->settings("use_relevanssi") == 1) { if ($query->query_vars['s'] != "") { if (function_exists('relevanssi_do_query')) { relevanssi_do_query($query); } } } if (!function_exists('sf_pagination_prev_next')) { function sf_pagination_prev_next($currentPage, $lastPage, $delim = " | ", $containertag = "", $childtag = "") { if ($lastPage > 1) { $returnHtml = ""; if ($containertag != "") { $returnHtml .= "<" . $containertag . ">"; } $returnHtml = get_previous_link($currentPage, $lastPage, $childtag) . $delim . get_next_link($currentPage, $lastPage, $childtag); if ($containertag != "") { $returnHtml .= "</" . $containertag . ">"; } echo $returnHtml; } } } if (!function_exists('sf_pagination_numbers')) { function sf_pagination_numbers($currentPage, $totalPage, $delim = " | ", $containertag = "", $childtag = "", $distance = 4) { if ($totalPage > 1) { $returnHtml = ""; $linksArray = array(); $startPage = $currentPage < 5 ? 1 : $currentPage - 4; $endPage = 8 + $startPage; $endPage = $totalPage < $endPage ? $totalPage : $endPage; $diff = $startPage - $endPage + 8; $startPage -= $startPage - $diff > 0 ? $diff : 0; if ($startPage > 1) { array_push($linksArray, '<a href="#" class="pagi-first" data-page-number="1">1</a> ...'); } for ($i = $startPage; $i <= $endPage; $i++) { $addClass = ''; if ($i == $currentPage) { $addClass = ' sf-active'; } array_push($linksArray, '<a href="#" class="pagi-num' . $addClass . '" data-page-number="' . $i . '">' . $i . '</a>'); } if ($endPage < $totalPage) { array_push($linksArray, '... <a href="#" class="pagi-last" data-page-number="' . $totalPage . '">' . $totalPage . '</a>'); } $returnHtml .= implode($linksArray, $delim); echo $returnHtml; } } } if (!function_exists('get_previous_link')) { function get_previous_link($currentPage, $lastPage, $containertag = "") { $returnHtml = ""; if ($containertag != "") { $returnHtml .= "<" . $containertag . ">"; } $prevLink = 1; $addClass = ""; if ($currentPage == 1) { $addClass = " sf-disabled"; } else { if ($currentPage - 1 >= 1) { $prevLink = $currentPage - 1; } } $returnHtml .= '<a href="#" class="pagi-prev' . $addClass . '" data-page-number="' . $prevLink . '">' . __("Previous", 'search-filter') . '</a>'; if ($containertag != "") { $returnHtml .= "</" . $containertag . ">"; } return $returnHtml; } } if (!function_exists('get_next_link')) { function get_next_link($currentPage, $lastPage, $containertag) { $returnHtml = ""; if ($containertag != "") { $returnHtml .= "<" . $containertag . ">"; } $addClass = ""; $nextLink = $lastPage; $addClass = ""; if ($currentPage == $lastPage) { $addClass = " sf-disabled"; } else { if ($currentPage + 1 <= $lastPage) { $nextLink = $currentPage + 1; } } $returnHtml .= '<a href="#" class="pagi-next' . $addClass . '" data-page-number="' . $nextLink . '" >' . __("Next", 'search-filter') . '</a>'; if ($containertag != "") { $returnHtml .= "</" . $containertag . ">"; } return $returnHtml; } } remove_filter('posts_where', array($this, 'filter_meta_query_where')); remove_filter('posts_join', array($this, 'filter_meta_join')); //print_r($query->request); ob_start(); //first check to see if there is a search form that matches the ID of this form if ($overridden_template = locate_template('search-filter/' . $sfid . '.php')) { // locate_template() returns path to file // if either the child theme or the parent theme have overridden the template include $overridden_template; } else { //the check for the default template (results.php) if ($overridden_template = locate_template('search-filter/results.php')) { // locate_template() returns path to file // if either the child theme or the parent theme have overridden the template include $overridden_template; } else { // If neither the child nor parent theme have overridden the template, // we load the template from the 'templates' sub-directory of the directory this file is in include plugin_dir_path(SEARCH_FILTER_PRO_BASE_PATH) . '/templates/results.php'; } } $returnvar .= ob_get_clean(); wp_reset_postdata(); return $returnvar; }
public function acCallback() { global $wpdb; $resultsPosts = array(); $resultsTerms = array(); $term = sanitize_text_field($_GET['term']); if (count($this->options['autocomplete_posttypes']) > 0) { // extra code added here to use Relevanssi instead of regular search if (!function_exists('relevanssi_do_query')) { $tempPosts = get_posts(array('s' => $term, 'numberposts' => $this->options['autocomplete_numrows'], 'post_type' => $this->options['autocomplete_posttypes'], 'post_status' => 'publish')); } else { $tempPosts = new stdClass(); $tempPosts->query_vars = array('s' => $term, 'numberposts' => $this->options['autocomplete_numrows'], 'post_type' => $this->options['autocomplete_posttypes'], 'post_status' => 'publish'); relevanssi_do_query($tempPosts); $tempPosts = $tempPosts->posts; } foreach ($tempPosts as $post) { if ($post->post_type == 'user') { $tempObject = array('id' => $post->user_id, 'type' => 'user', 'taxonomy' => null, 'postType' => $post->post_type); } else { $tempObject = array('id' => $post->ID, 'type' => 'post', 'taxonomy' => null, 'postType' => $post->post_type); } $linkTitle = apply_filters('the_title', trim(preg_replace('/\\[.*\\]/i', '', $post->post_title))); $linkTitle = apply_filters('search_autocomplete_modify_title', $linkTitle, $tempObject); if (!in_array('posts', $this->options['autocomplete_hotlinks'])) { $linkURL = '#'; } else { if ($post->post_type == "user") { $linkURL = $post->link; // default link to author page if (function_exists('bp_activity_screen_index')) { // if using BuddyPress - link to the members page $linkURL = str_replace('/author', '/members', $linkURL); } elseif (function_exists('bbp_get_displayed_user_field')) { // if using bbPress - link to the staff page $linkURL = str_replace('/author', '/staff', $linkURL); } if ($linkURL) { $linkURL = apply_filters('search_autocomplete_modify_url', $linkURL, $tempObject); } } else { $linkURL = get_permalink($post->ID); if ($linkURL) { $linkURL = apply_filters('search_autocomplete_modify_url', $linkURL, $tempObject); } } } if ($post->post_status == 'publish') { $resultsPosts[] = array('title' => $linkTitle, 'url' => $linkURL); } } } if (count($this->options['autocomplete_taxonomies']) > 0) { $taxonomyTypes = "AND ( tax.taxonomy = '" . implode("' OR tax.taxonomy = '", $this->options['autocomplete_taxonomies']) . "') "; $queryStringTaxonomies = 'SELECT term.term_id as id, term.name as post_title, term.slug as guid, tax.taxonomy, 0 AS content_frequency, 0 AS title_frequency FROM ' . $wpdb->term_taxonomy . ' tax ' . 'LEFT JOIN ' . $wpdb->terms . ' term ON term.term_id = tax.term_id WHERE ' . ' term.name LIKE "%' . $term . '%" ' . $taxonomyTypes . 'ORDER BY tax.count DESC ' . 'LIMIT 0, ' . $this->options['autocomplete_numrows']; $tempTerms = $wpdb->get_results($queryStringTaxonomies); foreach ($tempTerms as $term) { $tempObject = array('id' => $term->id, 'type' => 'taxonomy', 'taxonomy' => $term->taxonomy, 'postType' => null); $linkTitle = apply_filters('the_title', trim(preg_replace('/\\[.*\\]/i', '', $term->post_title))); $linkTitle = apply_filters('search_autocomplete_modify_title', trim(preg_replace('/\\[.*\\]/i', '', $linkTitle)), $tempObject) . " (" . ucfirst($term->taxonomy) . ")"; if (!in_array('taxonomies', $this->options['autocomplete_hotlinks'])) { $linkURL = '#'; } else { $linkURL = get_term_link($term->guid, $term->taxonomy); $linkURL = apply_filters('search_autocomplete_modify_url', $linkURL, $tempObject); } $resultsTerms[] = array('title' => trim(preg_replace('/\\[.*\\]/i', '', $linkTitle)), 'url' => $linkURL); } } if ($this->options['autocomplete_sortorder'] == 'posts') { $results = array_merge($resultsPosts, $resultsTerms); } else { $results = array_merge($resultsTerms, $resultsPosts); } $results = apply_filters('search_autocomplete_modify_results', $results); echo json_encode(array('results' => array_slice($results, 0, $this->options['autocomplete_numrows']))); die; }
function jv_query($relatedby, $post_id, $q, $postcount, $post_in = '', $post_not_in = '', $relevanssi = false) { global $extrp_settings; $s = extrp_related_by($post_id, $q, $postcount, $relatedby); $post_ids = extrp_search_postids_db($post_id, $postcount); $post__in = array_filter($post_in) ? array_diff($post_in, array($post_id)) : array(); $post__not_in = '' == $post_not_in ? array($post_id) : array_unique(wp_parse_args(array($post_id), $post_not_in)); $post__in_key = 'post__in' != $s[0] ? 'post__in' : ''; $post__in_val = 'post__in' != $s[0] ? $post__in : ''; $default = array('related_by' => $relatedby, 'post_type' => extrp_post_type(), 'posts_per_page' => $postcount, 'post_status' => 'publish', 'post__not_in' => $post__not_in, 'ignore_sticky_posts' => 1, $s[0] => $s[1], $post__in_key => $post__in_val); $additional = apply_filters('extrp_wp_query', array()); $args = wp_parse_args($additional, $default); $query = new WP_Query($args); if ($relevanssi) { relevanssi_do_query($query); } return $query; }
function relevanssi_query($posts, $query = false) { $admin_search = get_option('relevanssi_admin_search'); ($admin_search == 'on') ? $admin_search = true : $admin_search = false; global $relevanssi_active; $search_ok = true; // we will search! if (!is_search()) { $search_ok = false; // no, we can't } if (is_search() && is_admin()) { $search_ok = false; // but if this is an admin search, reconsider if ($admin_search) $search_ok = true; // yes, we can search! } if ($relevanssi_active) { $search_ok = false; // Relevanssi is already in action } if ($search_ok) { global $wp_query; $posts = relevanssi_do_query($wp_query); } return $posts; }
public function relevanssi_add_custom_filter($ids_array, $query_args, $sfid) { global $searchandfilter; $sf_inst = $searchandfilter->get($sfid); $this->remove_relevanssi_defaults(); if ($sf_inst->settings("use_relevanssi") == 1) { //ensure it is enabled in the admin if (isset($query_args['s'])) { //only run if a search term has actually been set if (trim($query_args['s']) != "") { //$search_term = $query_args['s']; if (function_exists('relevanssi_do_query')) { $expand_args = array('posts_per_page' => -1, 'paged' => 1, 'fields' => "ids", 'meta_key' => "", 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false); $query_args = array_merge($query_args, $expand_args); //$query_args['orderby'] = "relevance"; //$query_args['order'] = "asc"; unset($query_args['order']); unset($query_args['orderby']); // The Query $query_arr = new WP_Query($query_args); relevanssi_do_query($query_arr); $ids_array = array(); if ($query_arr->have_posts()) { foreach ($query_arr->posts as $post) { $postID = 0; if (is_numeric($post)) { $postID = $post; } else { if (is_object($post)) { if (isset($post->ID)) { $postID = $post->ID; } } } if ($postID != 0) { array_push($ids_array, $postID); } } } if ($sf_inst->settings("use_relevanssi_sort") == 1) { //keep a copy for ordering the results later $this->relevanssi_result_ids['sf-' . $sfid] = $ids_array; //now add the filter add_filter('sf_apply_filter_sort_post__in', array($this, 'relevanssi_sort_result_ids'), 10, 3); } return $ids_array; } } } } return array(false); //this tells S&F to ignore this custom filter }
/** * Initializes a WP_Query object with the given search parameters * * @since 1.0 */ function query() { $this->build_tax_query(); $this->build_meta_query(); $this->convert_orderby(); // Apply pagination if (get_query_var('paged')) { $paged = get_query_var('paged'); } else { if (get_query_var('page')) { $paged = get_query_var('page'); } else { $paged = 1; } } $this->wp_query_args['paged'] = $paged; $this->wp_query = new WP_Query($this->wp_query_args); $query = $this->wp_query; $query->query_vars['post_type'] = $this->wp_query_args['post_type']; if ($this->relevanssi) { include_once ABSPATH . 'wp-admin/includes/plugin.php'; if (!empty($_REQUEST['search_query']) && is_plugin_active('relevanssi/relevanssi.php')) { relevanssi_do_query($query); } } if (defined('WPAS_DEBUG') && WPAS_DEBUG) { echo '<pre>'; print_r($query); echo '</pre>'; } return $query; }
public function acCallback() { global $wpdb, $query, $wp_query; $resultsPosts = array(); $resultsTerms = array(); $term = sanitize_text_field($_GET['term']); if (count($this->options['autocomplete_posttypes']) > 0) { if (function_exists('relevanssi_do_query') && $this->options['autocomplete_relevanssi'] !== 'false') { $query->query_vars['s'] = $term; $query->query_vars['posts_per_page'] = $this->options['autocomplete_numrows']; $query->query_vars['post_type'] = $this->options['autocomplete_posttypes']; $query->query_vars['post_status'] = 'publish'; $query->query_vars['paged'] = 0; $query->is_admin = $wp_query->is_admin; relevanssi_do_query($query); $tempPosts = $query->posts; } else { $tempPosts = get_posts(array('suppress_filters' => false, 's' => $term, 'numberposts' => $this->options['autocomplete_numrows'], 'post_type' => $this->options['autocomplete_posttypes'])); } foreach ($tempPosts as $post) { $tempObject = array('id' => $post->ID, 'type' => 'post', 'taxonomy' => null, 'postType' => $post->post_type); $linkTitle = apply_filters('the_title', $post->post_title, $post->ID); $linkTitle = apply_filters('search_autocomplete_modify_title', $linkTitle, $tempObject); if (!in_array('posts', $this->options['autocomplete_hotlinks'])) { $linkURL = '#'; } else { $linkURL = get_permalink($post->ID); $linkURL = apply_filters('search_autocomplete_modify_url', $linkURL, $tempObject); } $resultsPosts[] = array('title' => $linkTitle, 'url' => $linkURL); } } if (count($this->options['autocomplete_taxonomies']) > 0) { $taxonomyTypes = "AND ( tax.taxonomy = '" . implode("' OR tax.taxonomy = '", $this->options['autocomplete_taxonomies']) . "') "; $queryStringTaxonomies = 'SELECT term.term_id as id, term.name as post_title, term.slug as guid, tax.taxonomy, 0 AS content_frequency, 0 AS title_frequency FROM ' . $wpdb->term_taxonomy . ' tax ' . 'LEFT JOIN ' . $wpdb->terms . ' term ON term.term_id = tax.term_id WHERE 1 = 1 ' . 'AND term.name LIKE "%' . $term . '%" ' . $taxonomyTypes . 'ORDER BY tax.count DESC ' . 'LIMIT 0, ' . $this->options['autocomplete_numrows']; $tempTerms = $wpdb->get_results($queryStringTaxonomies); foreach ($tempTerms as $term) { $tempObject = array('id' => $term->id, 'type' => 'taxonomy', 'taxonomy' => $term->taxonomy, 'postType' => null); $linkTitle = $term->post_title; $linkTitle = apply_filters('search_autocomplete_modify_title', $linkTitle, $tempObject); if (!in_array('taxonomies', $this->options['autocomplete_hotlinks'])) { $linkURL = '#'; } else { $linkURL = get_term_link($term->guid, $term->taxonomy); $linkURL = apply_filters('search_autocomplete_modify_url', $linkURL, $tempObject); } $resultsTerms[] = array('title' => $linkTitle, 'url' => $linkURL); } } if ($this->options['autocomplete_sortorder'] == 'posts') { $results = array_merge($resultsPosts, $resultsTerms); } else { $results = array_merge($resultsTerms, $resultsPosts); } foreach ($results as $index => $result) { $results[$index]['title'] = html_entity_decode($result['title']); } $results = apply_filters('search_autocomplete_modify_results', $results); echo json_encode(array('results' => array_slice($results, 0, $this->options['autocomplete_numrows']))); die; }
static function alter_results() { global $wp_query; relevanssi_do_query($wp_query); }
/** * Initializes and returns a WP_Query object for the search instance * * @return \WP_Query */ public function buildQueryObject() { //$query_args = $this->buildQuery(); $query = new Query($this->fields, $this->wp_query_args, $this->request); $query = new \WP_Query($query->getArgs()); $query->query_vars['post_type'] = empty($query_args['post_type']) ? 'post' : $query_args['post_type']; include_once ABSPATH . 'wp-admin/includes/plugin.php'; $search_query = $this->request->get(RequestVar::search); if (!empty($search_query) && $this->relevanssiActive()) { relevanssi_do_query($query); } $this->wp_query_obj = $query; return $query; }
if ($_GET['pt'] == 'forums') { $query->query_vars['s'] = $s; $query->query_vars['posts_per_page'] = 10; $query->query_vars['post_type'] = array('forum', 'topic', 'reply'); if (function_exists('relevanssi_do_query')) { relevanssi_do_query($query); } } if ($_GET['pt'] == 'user') { global $foundstaff; $foundstaff = 0; $query->query_vars['s'] = $s; $query->query_vars['posts_per_page'] = -1; $query->query_vars['post_type'] = array('user', 'team'); if (function_exists('relevanssi_do_query')) { relevanssi_do_query($query); } } ?> <h1><?php printf(__('Search results for: %s', 'twentyten'), '' . $s . ''); ?> </h1> <?php if ($_GET['pt'] == 'forums') { echo "<p class='news_date'>Showing results from forums. <a href='" . site_url() . "/?s="; echo the_search_query(); echo "'>Search the intranet</a></p>"; } if ($wp_query->found_posts > 1 && $_GET['pt'] != 'user') { echo "<p class='news_date'>Found " . $wp_query->found_posts . " results</p>";
$year = $query_args['year']; $monthnum = $query_args['monthnum']; $author = $query_args['author_name']; // create a new, simplified query $query_args = array('post_type' => $postType, 'posts_per_page' => $postsPerPage, 'cat' => $categoryId, 'paged' => get_query_var('paged') ?: 1, 'year' => $year, 'monthnum' => $monthnum, 'author_name' => $author); } // Handles search if (isset($_GET['search']) && !empty($_GET['search'])) { $query_args['s'] = $_GET['search']; } // Set up pagination if (!is_single()) { // Get posts wp_reset_query(); if (is_search()) { relevanssi_do_query($query_args); } else { query_posts($query_args); } // Setup Pagination $big = 99999999; $pagination_links = paginate_links(array('base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'format' => '?paged=%#%', 'current' => max(1, get_query_var('paged')), 'total' => $wp_query->max_num_pages, 'prev_text' => __('«'), 'next_text' => __('»'), 'type' => 'array')); } // Loops through the pages if (have_posts()) { while (have_posts()) { the_post(); $featured = get_field('post_call_to_action', get_the_ID()); ?> <div class="detailed-list-item <?php echo $featured === 'Image' || $featured === 'Video' ? "row" : null;
/** * wpv_fix_relevanssi_on_archive_loops * * On archive loops different from view_search-page that contain a search filter using content_extended modes, replace the query with the Relevanssi one. * On search archive loops, apply Relevanssi when needed. * In both cases, adjust when no post is returned by creating a dummy one and setting the loop_has_no_posts flag. * * @param $query WP_Query object * @param $args array * wpa_id * wpa_slug * wpa_settings * wpa_object * * @since 2.2 */ function wpv_fix_relevanssi_on_archive_loops($query, $args) { if ($query->query_vars["posts_per_page"] == -1) { $query->max_num_pages = 1; } if (!function_exists('relevanssi_prevent_default_request')) { return; } $do_relevanssi_query = false; if (isset($args['wpa_slug']) && $args['wpa_slug'] != 'view_search-page') { $wpa_settings = isset($args['wpa_settings']) ? $args['wpa_settings'] : array(); if (isset($wpa_settings['search_mode']) && isset($_GET['wpv_post_search']) && !empty($_GET['wpv_post_search'])) { $search_in = isset($wpa_settings['post_search_content']) ? $wpa_settings['post_search_content'] : 'full_content'; if ($search_in == 'content_extended') { $do_relevanssi_query = true; } } } else { if (is_search() && isset($_GET['s']) && !empty($_GET['s'])) { $do_relevanssi_query = true; } } if ($do_relevanssi_query) { $relevanssi_posts = relevanssi_do_query($query); $wpa_object = isset($args['wpa_object']) ? $args['wpa_object'] : null; if ($wpa_object) { if (empty($relevanssi_posts)) { $wpa_object->loop_has_no_posts = true; $query->post_count = 1; $dummy_post_obj = (object) array('ID' => $args['wpa_id'], 'post_author' => '1', 'post_name' => '', 'post_type' => '', 'post_title' => '', 'post_date' => '0000-00-00 00:00:00', 'post_date_gmt' => '0000-00-00 00:00:00', 'post_content' => '', 'post_excerpt' => '', 'post_status' => 'publish', 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_password' => '', 'post_parent' => 0, 'post_modified' => '0000-00-00 00:00:00', 'post_modified_gmt' => '0000-00-00 00:00:00', 'comment_count' => '0', 'menu_order' => '0'); $dummy_post = new WP_Post($dummy_post_obj); $query->posts = array($dummy_post); } else { $wpa_object->loop_has_no_posts = false; } } } }