Home › Forums › ACF PRO › Continuous loop in Relationship field with custom title + custom search › Reply To: Continuous loop in Relationship field with custom title + custom search
To be honest, I don’t understand the query that’s being done. For some reason it appears to me that the WHERE does not look correct, but that could be my lack of understanding of a very complex query.
This part seems particularly out of place
wp_posts.post_date DESCLIMIT 40, 20 JOIN
wp_icl_translations t ON wp_posts.ID = t.element_id
Looking at the entire query, that line does not seem, at least to me, to be part of either the clause before it or the one after it. Here is one of them broken down a bit with some white space to make it easier to look at.
AND wp_posts.post_type = 'property'
AND ((wp_posts.post_status <> 'trash' AND wp_posts.post_status <> 'auto-draft'))
AND ((t.language_code = 'pt-pt'
AND wp_posts.post_type IN ('post', 'page', 'acf-field-group', 'acf-field','property', 'testimonial'))
OR wp_posts.post_type NOT IN ('post', 'page', 'acf-field-group', 'acf-field', 'property', 'testimonial'))
wp_posts.post_date DESCLIMIT 40, 20 JOIN wp_icl_translations t ON wp_posts.ID = t.element_id
AND t.element_type = CONCAT('post_', wp_posts.post_type)
INNER JOIN wp_postmeta as METACF ON (wp_posts.ID = METACF.post_id)
You may need to find another way to do this. Is there some reason that you’re not using the filter provided by ACF for altering the relationship query? https://www.advancedcustomfields.com/resources/acf-fields-relationship-query/
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.