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

Reply To: Problem with acf relational field used as filter

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Problem with acf relational field used as filter Reply To: Problem with acf relational field used as filter

#31593
Ernest MarcinkoErnest Marcinko
Keymaster

Sure, but getting the values printed is not the biggest issue. Filtering the actual results via the search query is what makes this almost impossible.

How I would recommend doing this is using the filters API to create new filters of your choice. That is for the frontend.
When creating the filter, choose a non-existent field name, so the plugin does not try to resolve it – as it would result in no results whatsoever. You can recognize this field in the next section, when you treat the actual results. Also, make sure you have this option enabed, so missing fields does not empty the result set.

Once you have the filters you need to treat the results. Instead of trying to make a custom query I would recommend removing the results within the post process via the asp_results filter. There you have access to the initial query arguments via the $args variable (4th argument). The filter values passed on are stored in the $args['post_meta_filter'] (referenced here).
With that information you can loop through the results and perhaps remove the ones that does not fit the query.

However I can not guarantee this is going to work, this is not an easy thing to implement by any means.