[Resolved] ordering custom fields in the translation editor correctly
This thread is resolved. Here is a description of the problem and solution.
Problem:
I have set up a bunch of custom fields for a post type using ACF. These will be translated using the translation editor. However, the custom fields appear in the order that they were added to the database, which does not match the order they are in when editing the posts. The order of custom fields in the posts follows that of the ACF field group and this order can be re-arranged, for example after adding more custom fields.
Solution:
WPML is not made to update based on the order changes that you made on the field group. This is gonna work only on the WordPress editor, but the WPML translation editor has no logic implemented for this.
Tell us what you are trying to do?
I have set up a bunch of custom fields for a post type using ACF. These will be translated using the translation editor. However, the custom fields appear in the order that they were added to the database, which does not match the order they are in when editing the posts. The order of custom fields in the posts follows that of the ACF field group and this order can be re-arranged, for example after adding more custom fields.
I would like the order of the custom fields in the translation editor to follow that of the post I'm translating (i.e. the field group in ACF). This is much easier to understand for the staff members adding the translations, who do not speak great English.
I've seen a few forum posts about the same topic, but they were closed without offering any solutions.
Is there a way to achieve this?
If not, can this option be added?
Is there any chance that you could create a short video about how you are using the custom fields and how you're translating them, please? I just want to understand exactly what are the changes that you're making so I can do the same on my testing website and see what we can do about this.
You can use an online tool like loom.com or screencast-o-matic.com in order to make this video.
Can you fully translate the page, then make a small change to the original page, then edit the translation again, please? This time, the order of the custom fields will change (I just tested this out on my website).
Basically, when you start a translation, WPML is scanning the original page and gives you all the elements for translation. He also gets the order of the custom fields too. After that, the original page won't be scanned again for the strings or the order of the custom fields unless you make a change on it. This way we save a lot of requests when you are editing the page translation (this is really helpful when you have a lot of elements on the page and scanning a big page would consume a lot of resources of the server).
Can you give this a try and tell me if things are working fine for you too, if you make this change, please?
Thanks for your speedy reply.
I hadn't started translation for any of the pages before I changed the order of items in the ACF field groups though? I started the translation AFTER the order of items was changed in ACF. Therefore, shouldn't WMPL then scan the correct order?
Or how did you do it in your case?
It seems to me that WMPL is sorting by creation date of the custom fields in the database.
What I did was to create the custom fields, use the on the page, translate the page (including the custom fields), then change the order of the custom fields. Now I made a change on the page with the custom fields (I changed the text of a custom field) and when I edited the translated page, the order of the custom fields changed too.
Can you try to do this change on your website too and let me know how it goes, please?
Okay, I've tried, but it has the same outcome.
As mentioned, none of the pages had been translated yet, so supposedly WPML had never scanned them for custom fields before.
Looking at wp_postmeta table in the database, the meta_id numbering seems to follow the original field order in the ACF field group, i.e. lower meta_id numbers appeared above higher numbers in the field group. However, WPML is not following either this original order or the updated one. The field order in WPML seems completely random to me.
I was able to replicate this issue on a clean install (when I tried to do the same yesterday, things worked fine for some unknown reason). Also, thank you for the info that you added to your last reply.
In the meantime, I run a couple more tests with the custom fields but couldn't make them change the order, no matter what I've been trying to do. In this case, I had to pass this to my colleagues and let them have a look at this. I'll keep you posted as soon as I have an update (which shouldn't take long).
I talked with my colleagues about this, as I promised. However, it turns out that WPML is not made to update based on the order changes that you made on the field group.
This is gonna work only on the WordPress editor, but the WPML translation editor has no logic implemented for this, at least for now.
Thanks for following up Radu.
I was considering switching to translating via the WordPress editor already, due to other issues, e.g. Elementor strings showing up in the translation editor on each page.
I remember when WPML used to make translating much easier, but these issues with both ACF and Elementor are proving serious limitations.