I think there’s a bug in either Polylang or ACF. If you have a relationship field on a page, that’s set to list just a single custom post type, the field’s value gets saved to database, but after a page reload it appears as if it hasn’t been saved.
You can circumvent the issue by activating that custom post type in Polylang settings for translation, but if you don’t want to translate the particular CPT, this is not really optimal.
I’m actually facing the exact same issue! Also weird is that when loading the field, no “non-translatable” CPT posts are visible, but when doing AJAX request, they become visible. After saving, nothing seems to be selected but in post_meta I can see that a non-translatable post is selected.
I’ve come to a conclusion that the issue is a polylang issue rather than ACF issue. If one is using only “post__in” and “post_type” in wp_query, it shouldn’t make a difference in which language the request is made in as we has the IDs. Alternative solution would be to change ACF Core class-acf-field-relationship.php to iterate over every saved ID and map its content to a new array with “get_post”. “get_posts” with “post__in” does not work but “get_post” with single ID works.
I have found that the standard way of pulling posts, acf_get_posts, does not put in a lang argument into the query. So if you have a cpt that should be across multiple languages but no lang=”, you will have them not showing up. I am trying to work out a solution for this too!
The topic ‘Polylang relationship field oddities’ is closed to new replies.
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!