Tagged: ajax, relevanssi, search
-
AuthorPosts
-
August 10, 2013 at 12:03 am #27531
I was having a problem with search results prioritizing content over titles, so I installed Relevanssi and it fixed the issue. The problem I’m having now is that it only fixed the issue in the search results, but the instant search is unchanged.
Is there a way to make these match up? Or can you point me in the direction of where instant search is pulling its search data?
Here’s an example of what’s happening: https://www.evernote.com/shard/s260/sh/11f263db-26cf-4c58-b252-4ba2e5914440/469714435e9de6c91a59b1ee57f13050
August 12, 2013 at 7:39 pm #134316Hey!
The ajax search is powered by the avia_ajax_search function in functions-enfold.php
The function has several filters that makes customization of the search parameters easy, but I am not sure if it will be enough for Relevanssi to hook into it.
August 14, 2013 at 8:40 pm #134317Is there a simple way to edit the PHP in order to prioritize the page/blog names over the page content?
August 15, 2013 at 4:15 am #134318Hi rapinion,
Not that I know of no. The theme is just using the WordPress query which you can read a bit more about here: https://codex.wordpress.org/Class_Reference/WP_Query#Search_Parameter
Regards,
Devin
August 26, 2013 at 7:21 am #134319in relevanssi you can change the weighing of the POST/PAGE/TAXAMONY etc i think.
it would be nice when the ajax search uses the relavanssi query.
mAqq
August 26, 2013 at 8:50 am #134320You can use Relevanssi for the ajax search query. Open up enfoldfunctions-enfold.php and replace
$defaults = array('numberposts' => 5, 'post_type' => 'any', 'post_status' => 'publish', 'post_password' => '', 'suppress_filters' => false);
$_REQUEST['s'] = apply_filters( 'get_search_query', $_REQUEST['s']);
$query = array_merge($defaults, $_REQUEST);
$query = apply_filters('avf_ajax_search_query', http_build_query($query) );
$posts = get_posts( $query );with
$defaults = array('numberposts' => 5, 'post_type' => 'any', 'post_status' => 'publish', 'post_password' => '', 'suppress_filters' => false);
$_REQUEST['s'] = apply_filters( 'get_search_query', $_REQUEST['s']);
$searchquery = array_merge($defaults, $_REQUEST);
if(!function_exists('relevanssi_do_query'))
{
$searchquery = apply_filters('avf_ajax_search_query', http_build_query($searchquery));
$posts = get_posts($searchquery);
}
else
{
global $query;
$tempquery = $query;
$searchquery = apply_filters('avf_ajax_search_query', $searchquery);
$tempquery->query_vars = $searchquery;
relevanssi_do_query($tempquery);
$posts = $tempquery->posts;
}August 29, 2013 at 10:01 am #134321Works absolutely perfect, just tested it. Thanks, Dude!
August 29, 2013 at 11:09 am #134322We added a filter to the theme. In the next version you’ll be able to include this code without modifying the function (eg you can use a child theme then). I’ll post the code here when we released the update.
Update – with the next version following code should be used instead
add_filter('avf_ajax_search_function', 'avia_init_relevanssi', 10, 4);
function avia_init_relevanssi($function_name, $search_query, $search_parameters, $defaults)
{
$function_name = 'avia_relevanssi_search';
return $function_name;
}
function avia_relevanssi_search($search_query, $search_parameters, $defaults)
{
global $query;
$tempquery = $query;
$tempquery->query_vars = $search_parameters;
relevanssi_do_query($tempquery);
$posts = $tempquery->posts;
return $posts;
} -
AuthorPosts
- The topic ‘Instant search not matching search results’ is closed to new replies.