Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › search show all results › Reply To: search show all results
December 27, 2022 at 3:11 pm
#40649
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;
}