Home › Forums › Front-end Issues › Nesting relationship querys › Reply To: Nesting relationship querys
I think my previous comment didn’t post! Sorry about that.
Your query is nearly there. Just check out this doc:
You need to make a few modifications to add the LIKE query work. Also, updating to ACF 4.3.0 will ensure that the data is saved in this LIKE friendly format (it is possible that 4.2.2 did not)
Basically, within your loop foreach speaker, you can perform your get_posts query asking for all videos which have selected the current speaker ID and the event ID.
Your code already shows you have figured out this logic.
Something that I can see causing an issue is the setup_postdata function. This is a great function for a single loop, however once you proceed into the nested loop (video), this function will cause all sorts of issues. Basically, it will kill the speakers loop completely!
I would instead, not use the setup_postdata function, but just pass the current ID into all the WP functions. Also, you will need to change your loop to not use the $post variable, instead use $speaker or $event. You can get a title like so:
echo get_the_title( $speaker->ID );
Hope that helps.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🚨 The 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5— Advanced Custom Fields (@wp_acf) May 18, 2023
© 2023 Advanced Custom Fields.