Home › Forums › Front-end Issues › Conditional statement for relationship field? › Reply To: Conditional statement for relationship field?
The principal difference is your code executes a query, wich if the $ids is empty the query with the argument “post__in” will be empty, so retrieves all of the testimonials posts, and then checks if you have $ids or not. So this does a call to the database and then checks for the $ids.
In my code checks if you have $ids or not, if you don’t have $ids then don’t do the query (which means don’t do a call to the database)
I hope this helps you.
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!
🤔 Curious about the ACF user experience? So are we! Help guide the evolution of ACF by taking part in our first ever Annual Survey and guarantee you’re represented in the results. https://t.co/0cgr9ZFOJ5— Advanced Custom Fields (@wp_acf) May 8, 2023
© 2023 Advanced Custom Fields.