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.

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

You must be logged in to reply to this topic.

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.