I am trying to use https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts to filter a CPT by the data inside the intermediary posts connected to it.
my post type is reps, and it is connected to manufacturers with a many-to-many relationship with an intermediary post. inside the intermediary post i have products. I want to filter the reps by the products. I have a solution that somewhat works, but not with ajax and i can't understand why
i added an additional search field hidden link here hidden link
then I added the code to actually return the correct parents using the toolset_get_related_posts
hidden link
the search works perfectly if i load the page with the URL parameters, but if you just use the search form which uses ajax, the filter does nothing
Ajax search - not working. hidden link
Page load - working. hidden link
Args are correct. hidden link
the filter works if you go here: hidden link
but not if you just go here hidden link and use the search form
this is confusing, since I have a similar code that works perfectly which filters 'contacts' which is a RFG in reps. mentioned here: https://toolset.com/forums/topic/filter-posts-by-their-repeatable-field-group-data/
is there anything i need to change to make it work with ajax within toolset?
you can see the filter in action here: hidden link
you'll need to log in fist with this one-click login hidden link
My issue is resolved now. Thank you!