Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › search show all results
This topic contains 9 replies, has 2 voices, and was last updated by Ernest Marcinko 1 year, 2 months ago.
- AuthorPosts
- December 20, 2022 at 6:43 pm #40607
We using here your plugin (bottom section of website):
https://www.my-mobility.group/hess/45186-2/
Type “Markus Moser” or any other search string and you will see a lot of results which does not contain this word.
But the result box show all this results.Do you have an idea how to limit the search only for posts which contain the searched words?
We using this filter in functions.php:
add_filter('asp_query_cpt', 'asp_change_query_directly', 10, 1); function asp_change_query_directly($q) { global $wpdb; $q = preg_replace('/AND ' . preg_quote("$wpdb->posts.post_parent IN ") . '\((.*?)\)/im', "OR ($wpdb->posts.post_type IN ('post', 'page', 'dealer', 'vehicle', 'contact-person') AND $wpdb->posts.post_status LIKE 'publish' AND $wpdb->posts.post_parent IN($1))", $q); return $q; } add_filter( 'asp_query_args', 'asp_include_only_parent_ids', 10, 2 ); function asp_include_only_parent_ids( $args, $id ) { if ( $id == 3 ) { $args['post_parent'] = array(11748, 11754, 29487, 29888, 13423); $args['post_meta_filter'][] = array( 'key' => 'ad_location', 'value' => array('62b9acbc2709e'), 'operator' => 'ELIKE', 'allow_missing' => false ); } else if ( $id == 12 ) { $args['post_parent'] = array(3239, 24819); $args['post_meta_filter'][] = array( 'key' => 'ad_location', 'value' => array('62b996ad1edbc', '62b997647e701', '62b99783635d8', '62b9979cd0b48'), 'operator' => 'ELIKE', 'allow_missing' => false ); }
We using regular engine.
We using php 7.4.
We cleaned the cache.December 21, 2022 at 3:12 pm #40618Hi,
Have you tried removing the custom code first, to see if that changes the outcome? First, make sure to remove the custom code and let me know what happens then.
If it does not change, then the strings must be present somewhere in the results. I tried to log-in but the username/pass does not seem to work. Can you please check that too?
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
December 21, 2022 at 3:47 pm #40621You cannot access this content.December 27, 2022 at 2:51 pm #40642Hi,
The issue is caused by the custom codes unfortunately. Once I remove them both the plugin starts to work all right.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
December 27, 2022 at 2:58 pm #40646You cannot access this content.December 27, 2022 at 3:11 pm #40649I have disabled the custom codes below temporarily to test. The first one is more problematic and causes all the results to show, as it directly affects the query – but the second one also has an effect on the outcome.
Best,add_filter('asp_query_cpt', 'asp_change_query_directly', 10, 1); function asp_change_query_directly($q) { global $wpdb; $q = preg_replace('/AND ' . preg_quote("$wpdb->posts.post_parent IN ") . '\((.*?)\)/im', "OR ($wpdb->posts.post_type IN ('post', 'page', 'dealer', 'vehicle', 'contact-person') AND $wpdb->posts.post_status LIKE 'publish' AND $wpdb->posts.post_parent IN($1))", $q); return $q; } add_filter( 'asp_query_args', 'asp_include_only_parent_ids', 10, 2 ); function asp_include_only_parent_ids( $args, $id ) { if ( $id == 3 ) { $args['post_parent'] = array(11748, 11754, 29487, 29888, 13423); $args['post_meta_filter'][] = array( 'key' => 'ad_location', 'value' => array('62b9acbc2709e'), 'operator' => 'ELIKE', 'allow_missing' => false ); } else if ( $id == 12 ) { $args['post_parent'] = array(3239, 24819); $args['post_meta_filter'][] = array( 'key' => 'ad_location', 'value' => array('62b996ad1edbc', '62b997647e701', '62b99783635d8', '62b9979cd0b48'), 'operator' => 'ELIKE', 'allow_missing' => false ); } else if ( $id == 13 ) { $args['post_parent'] = array(3238, 20020, 19966, 24391, 19733); $args['post_meta_filter'][] = array( 'key' => 'ad_location', 'value' => array('62b996ad1edbc', '62b997647e701', '62b99783635d8', '62b9979cd0b48'), 'operator' => 'ELIKE', 'allow_missing' => false ); } else if ( $id == 7 ) { $args['post_parent'] = array(1927); $args['post_meta_filter'][] = array( 'key' => 'ad_location', 'value' => array('630340aae1cd1'), 'operator' => 'ELIKE', 'allow_missing' => false ); } else if ( $id == 8 ) { $args['post_parent'] = array(3235, 23542); $args['post_meta_filter'][] = array( 'key' => 'ad_location', 'value' => array('62b998fbdcd2f'), 'operator' => 'ELIKE', 'allow_missing' => false ); } else if ( $id == 21 ) { $args['post_parent'] = array(3715, 15640, 3729, 3721, 4636); $args['post_meta_filter'][] = array( 'key' => 'ad_location', 'value' => array('62b9acbc2709e'), 'operator' => 'ELIKE', 'allow_missing' => false ); } else if ( $id == 11 ) { $args['post_parent'] = array(3242, 29878, 29901, 18014, 29878); $args['post_meta_filter'][] = array( 'key' => 'ad_location', 'value' => array('630342bc01bbe'), 'operator' => 'ELIKE', 'allow_missing' => false ); } else if ( $id == 9 ) { $args['post_parent'] = array(10346, 10395, 10323); $args['post_meta_filter'][] = array( 'key' => 'ad_location', 'value' => array('63034222d8224'), 'operator' => 'ELIKE', 'allow_missing' => false ); } return $args; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 3, 2023 at 9:30 am #40688You cannot access this content.January 3, 2023 at 2:15 pm #40695You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 3, 2023 at 4:06 pm #40710You cannot access this content.January 4, 2023 at 2:14 pm #40745You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.