This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: asp_query_args & post_in

#35209
willfaulds59willfaulds59
Participant

Another dead end 🙁

add_filter("asp_query_args", "asp_query_args_change", 10, 2);
function asp_query_args_change($args, $search_id) {
	
	//WORKAROUND:set a search term?
	// $args[s]=searchterm
	// &asp_s='+encodeURIComponent('related_items:')
	// &asp_s=related_items%3A
	
	//as this is loaded via AJAX I cannot access the query string, $_REQUEST doesn't hold the referer URL either :(	
	
	if($args['s'])
	{	
		$searchterm = $args['s'];
		if ( strpos( $searchterm, 'related_items:' ) !== false) {
			$id_string = str_replace('related_items:', '', $searchterm);
			$ids = explode(',',$id_string);
			$args['post_in'] = array_unique( $ids );
			$args['s']='';
		}
	}

	//TODO stop the search term showing in search box
	return $args;
}

I thought I had a great workaround but unfortunately the $args[‘post_in’] seems to only apply to standard WP posts?

Any better solutions/imporvements for WC products?