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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.