Skip Navigation

[Resolved] filtering CPT by intermediary post data

This support ticket is created 4 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 1 reply, has 1 voice.

Last updated by BrandenT2154 4 years, 5 months ago.

Author
Posts
#1707071

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

#1707209

My issue is resolved now. Thank you!