Support

Account

Home Forums Bug Reports Polylang relationship field oddities

Solving

Polylang relationship field oddities

  • 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.

  • Apparently if you change the return type to “id” you will get the hidden saved values out. Now the only thing missing is to figure out why saved values are not coming up as selected after a load.

  • Did some further debugging, apparently the relationship fields results use wp_query with “post__in” parameters with proper IDs, hence I feel like this should work out of the box but for some reason stays hidden.

  • 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’m still having that problem with updated plugin. Has there been a workaround found? I’m trying to synchronize a relationship field listing non-translatable cpt and it doesn’t work on the second language.

  • 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!

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Polylang relationship field oddities’ is closed to new replies.