Tagged: ajax, ajax search, limit, search results
-
AuthorPosts
-
January 14, 2015 at 10:55 am #379357
For “SearchWP” there is an option to limit the ajax search results:
// limit the results to 5 function avia_searchwp_search_num_results() { return 5; } add_filter( 'searchwp_posts_per_page', 'avia_searchwp_search_num_results' );
Is there a similar setting for “Relevanssi”? For some search terms the list really gets too long on my page.
January 14, 2015 at 9:40 pm #379748Hi StuWeTueHo!
I found this which may help, http://www.relevanssi.com/knowledge-base/posts-per-page/.
Cheers!
ElliottJanuary 15, 2015 at 10:15 am #379934Thanks Elliott, but it only works for the standard search page. Maybe the provided code inside of my question was a little misleading. My question was targeting the AJAX search results.
January 15, 2015 at 8:51 pm #380418Hi!
Our AJAX search form limits the results to 5. Send us a link to your search page results so we can get a better idea of what your referring to.
Best regards,
ElliottFebruary 28, 2015 at 2:00 pm #403836I would appreciate help with this issue too! Using Relevanssi and searching for a common term results in a too long Ajax search results list, it is impossible to scroll down to see the complete list or go to the view all results link. Try searching for barcode here: http://www.abol.ac.at/en/ to see the Ajax search result list.
March 2, 2015 at 7:09 am #404320Hi!
Go to the Relevanssi panel then increase the Minimum word length to index: value to at least 4 then resave the index. You will get fewer and more relevant results when using the ajax search. Also, the theme’s ajax search returns a maximum of 5 items per post types, you can decrease that by adding this filter to the functions.php file:
add_filter('avf_ajax_search_query', 'avf_modify_ajax_search_query', 10, 1); function avf_modify_ajax_search_query($search_parameters) { parse_str($search_parameters, $params); $params['numberposts'] = 3; $search_parameters = http_build_query($params); return $search_parameters; }
Adjust the numberposts parameter.
Cheers!
IsmaelMarch 2, 2015 at 7:41 pm #404731Thank you for your advice! Increasing the Minimum word length to index is no option, because DNA has to stay a search term.
I also tried adding the filter you suggested, but unfortunately this didn’t change anything. A scrollbar of the ajax search results would be great like e.g. here: http://www.mindtheproduct.comMarch 3, 2015 at 9:38 am #405022Hi!
Add this to the Quick CSS field:
.avia-search-tooltip form#searchform { overflow-y: auto; }
If it doesn’t work, use this:
.avia-search-tooltip form#searchform { overflow-y: scroll; }
Cheers!
IsmaelMarch 3, 2015 at 10:12 am #405032Thank you! The first code isn’t working, the second code displays a scrollbar, but this bar isn’t scrolling, please try yourself: http://www,.abol.ac.at search term barcode or DNA
March 5, 2015 at 2:19 am #406178Hey!
Use this code instead:
.ajax_search_response { max-height: 300px; overflow-y: scroll; }
Best regards,
JosueMarch 5, 2015 at 9:46 am #406283Thank you very much! This code did the trick!
March 5, 2015 at 10:10 am #406300You are welcome, always glad to help :)
Regards,
Josue -
AuthorPosts
- The topic ‘Limit ajax search results with Relevanssi’ is closed to new replies.