search show all results

This topic contains 9 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 4 weeks ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #40607
    23volt
    23volt
    Participant

    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.

    #40618
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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 :)


    #40621
    23volt
    23volt
    Participant
    You cannot access this content.
    #40642
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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 :)


    #40646
    23volt
    23volt
    Participant
    You cannot access this content.
    #40649
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    I 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.

    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;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #40688
    23volt
    23volt
    Participant
    You cannot access this content.
    #40695
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #40710
    23volt
    23volt
    Participant
    You cannot access this content.
    #40745
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.