Tagged: ajax, relevanssi, search results
-
AuthorPosts
-
August 11, 2016 at 10:30 am #671236
Hello Enfold,
Thanks for your fantastic theme. I use relevanssi instead of the default WordPress default search engine as described here: I have a few questions about the search results presentation.
1. AJAX search display the pagebuilder code. If possible I would like to show highlighted text with search word here or it this is not possible the exerpt. How do I fix this?
2. How do I exclude ‘avia button text’ from indexing and search results?
Best regards,
Lennart
August 11, 2016 at 2:25 pm #671332Hi lenvo!
Please go to Appearance > Editor and edit functions-enfold.php file and find
$output .= $search_messages['another_search_term'];
and change it to
$output .= do_shortcode($search_messages['another_search_term']);
Best regards,
YigitAugust 19, 2016 at 10:43 am #674647Thanks for your reply Yigit ! Unfortunately, the problems have not been solved . I have been able to hide the buttons text of the search results page by converting them into widgets ( and exclude). However, still not all the shortcode stripped from my search results. See below for an example of visible shortcode content in serach results from Easy Slider pagination. How do I fix this so all shortcodes are stripped?
My second question is about the ajax functionality. I’m still not managed to replace the shortcodes for highlighted text without shortcodes displayed. I’ve tried your solution but this did not work for me. Is this not a common problem when replacing default search by Relevanssi? I’m not sure if so, but I guess I have to customize AJAX functionality as seen below. Do you have a solution to strip the shortcodes from AJAX search?
Front-end:
Thanks in advance for your help. Looking forward for your answers.
- This reply was modified 8 years, 3 months ago by lenvo. Reason: Added image front-end AJAX functionality
August 23, 2016 at 3:42 am #676127Hi,
Another workaround is to edit the pages and add a custom excerpt or summary to it. The ajax search will display this text instead of the builder content.
Best regards,
IsmaelAugust 23, 2016 at 12:01 pm #676323Hello Ismael,
1. I would like to show highlight content instead of the page excerpt. As you can see in the first image of my last post not all shortcodes are stripped. How do I fix this?
2. I’ve edited the excerpt function for ‘AJAX live search’ in functions-enfold.php as you can see below. The excerpt of the page is now shown in live search. But how do I show content like on my resultpage without shortcodes instead?
$excerpt = trim(get_the_excerpt()); if(!empty($post->post_excerpt)) { $excerpt = apply_filters( 'the_excerpt', get_the_excerpt( $post->ID ), $post>post_excerpt,70," ","...", true, '', true ); //$excerpt = apply_filters( 'avf_ajax_search_excerpt', avia_backend_truncate($post->post_excerpt,70," ","...", true, '', true) ); } else { $excerpt = apply_filters( 'the_excerpt', get_the_excerpt( $post->ID ), $post>post_excerpt,70," ","...", true, '', true ); //$excerpt = apply_filters( 'avf_ajax_search_no_excerpt', get_the_time($search_messages['time_format'], $post->ID), $post ); }
Looking forward for your reply.
Best regards,
Lennart
August 23, 2016 at 12:05 pm #676328One more question about live search:
3. I tried the code below for functions.php to limit ajax live search results when using relevanssi but not any of them work for me. How do I limit ajax search results using relevanssi?
Not working on my website:
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; }
August 26, 2016 at 10:05 am #678032Hi Enfold!
Any suggestions? Here is the update to my questions:
1. How do I limit ajax search results with Relevanssi? The following code did not work for me:
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; }
2. As I told the ‘easy slider’ shortcode was not fully stripped. So my search results returned ‘Previous Next 1 2 3 4 5’ (depending on how much slided). I fixed this with the following code in functions.php
add_filter('relevanssi_pre_excerpt_content', 'rlv_remove_flipbook'); function rlv_remove_flipbook($content) { $content = preg_replace('/\[\/av_slideshow]/', '', $content); return $content; }
3. I changed code in enfold-functions.php so my ajax results show the except. If possible I still would like to show highlight page content here as on my search result page. Is this possible?
Thanks in advance for the support!
August 28, 2016 at 6:29 am #678569Hi,
1.) Replace the avia_relevanssi_search function with the following:
function avia_relevanssi_search($search_query, $search_parameters, $defaults) { global $query; $tempquery = $query; if(empty($tempquery)) $tempquery = new WP_Query(); $search_parameters['numberposts'] = 3; $tempquery->query_vars = $search_parameters; relevanssi_do_query($tempquery); $posts = $tempquery->posts; return $posts; }
3.) I’m sorry but what do you mean by “highlight page content”?
Best regards,
IsmaelAugust 30, 2017 at 2:58 pm #845826Hi @Ismael,
i use the relevanssi plugin as well and have the same problem with the limitation of the ajax search on main page.
DEV-environment to a clients page
(Search is in burger menu)if you search for example “matratzen” (german for mattresses) you get almost 30 results.
I tried your code “avia_relevanssi_search function” but no change.is there a another way to resolve this problem.
best regards
RubenSeptember 1, 2017 at 9:30 am #846719Hi,
Replace the code with:
function avia_relevanssi_search($search_query, $search_parameters, $defaults) { global $query; $tempquery = $query; if(empty($tempquery)) $tempquery = new WP_Query(); $tempquery->query_vars = $search_parameters; relevanssi_do_query($tempquery); $posts = array_slice($tempquery->posts, 0, 5); return $posts; }
Limit the post by adjusting the value on this line.
$posts = array_slice($tempquery->posts, 0, 5);
Default is 5.
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.