This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This thread is resolved. Here is a description of the problem and solution.

Problem: I expected to see:

The Spanish-version post to be published with the ACF fields populated with the English content.

Instead, I got:

Fatal error: Uncaught InvalidArgumentException: element_id and type do not match for element_id:847 the database contains post_attachment while this function was called with post_page in /{redacted}/wp-content/plugins/sitepress-multilingual-cms/classes/core-abstract-classes/class-wpml-set-language.php:32 Stack trace: #0 /{redacted}/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php(1489): WPML_Set_Language->set(847, 'post_page', '45', 'es', 'en', true) #1 /{redacted}/wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-post-translation.class.php(325): SitePress->set_element_language_details(847, 'post_page', '45', 'es', 'en') #2 /{redacted}/wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-post-translation.class.php(172): WPML_Post_Translation->maybe_set_elid('45', 'page', 'es', 847, 'en') #3 /{redacted}/wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-admin-post-ac in /{redacted}/wp-content/plugins/sitepress-multilingual-cms/classes/core-abstract-classes/class-wpml-set-language.php on line 32

Solution: WPML -> Support -> Troubleshooting link -> Applied the troubleshooting steps pointed out in the attached image.

Relevant Documentation:

This topic contains 8 replies, has 2 voices.

Last updated by aaronF-4 4 months, 3 weeks ago.

Assigned support staff: Carlos Rojas.

Author Posts
May 19, 2019 at 9:24 pm

aaronF-4

I am trying to:

Integrate WPML into a site that uses Advanced Custom Fields for all post/page content. The client wants to provide their own Spanish translations for some of the English content.

I installed all plugins (WPML Multilingual CMS, WPML String Translation, WPML Translation Management, WPML Media and Advanced Custom Fields Multilingual) and ran through the prompted setup processes.

Once that was complete, I began testing using the "About" page.

I followed this guide (https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/) and set the "Translation preferences" for all of the fields that appear on this page to "Copy" and saved. I confirmed that these were set in the English (default) version of the page's "Multilingual Content Setup" options.

The "Use WPML's Translation Editor" setting is off for the page.

Link to a page where the issue can be seen:

This occurs in the admin area when attempting to publish a page/post (see attached screenshots), so no public link available.

I expected to see:

The Spanish-version post to be published with the ACF fields populated with the English content.

Instead, I got:

Fatal error: Uncaught InvalidArgumentException: element_id and type do not match for element_id:847 the database contains post_attachment while this function was called with post_page in /{redacted}/wp-content/plugins/sitepress-multilingual-cms/classes/core-abstract-classes/class-wpml-set-language.php:32 Stack trace: #0 /{redacted}/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php(1489): WPML_Set_Language->set(847, 'post_page', '45', 'es', 'en', true) #1 /{redacted}/wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-post-translation.class.php(325): SitePress->set_element_language_details(847, 'post_page', '45', 'es', 'en') #2 /{redacted}/wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-post-translation.class.php(172): WPML_Post_Translation->maybe_set_elid('45', 'page', 'es', 847, 'en') #3 /{redacted}/wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-admin-post-ac in /{redacted}/wp-content/plugins/sitepress-multilingual-cms/classes/core-abstract-classes/class-wpml-set-language.php on line 32

May 20, 2019 at 8:57 am #3845107

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Montevideo (GMT-03:00)

Hello,
Thank you for contacting WPML support.

I would like to ask you to follow this steps in order to isolate the cause of the issue:
- Back up your site first before making any change, this is for security reasons.
- Flush any cache memory that might exists.
- Deactivate all the plugins that are not related to WPML and ACF.
- Switch for a moment to a WordPress default theme like Twenty Seventeen.
- If the issue is gone, activate one by one to see with which one there is an interaction issue.

Could you tell me the result of this steps?

Kind regards,
Carlos

May 20, 2019 at 4:09 pm #3848671

aaronF-4

Hello,

I installed the WordPress 2019 theme and activated it. Then I deactivated all plugins except for the following:

- Advanced Custom Fields Multilingual
- Advanced Custom Fields PRO
- Classic Editor
- WPML Media
- WPML Multilingual CMS
- WPML String Translation
- WPML Translation Management

Attempting to save a page gives the same error as before:

Fatal error: Uncaught InvalidArgumentException: element_id and type do not match for element_id:857 the database contains post_attachment while this function was called with post_page in /{redacted}/wp-content/plugins/sitepress-multilingual-cms/classes/core-abstract-classes/class-wpml-set-language.php:32 Stack trace: #0 /{redacted}/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php(1489): WPML_Set_Language->set(857, 'post_page', '52', 'es', 'en', true) #1 /{redacted}/wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-post-translation.class.php(325): SitePress->set_element_language_details(857, 'post_page', '52', 'es', 'en') #2 /{redacted}/wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-post-translation.class.php(172): WPML_Post_Translation->maybe_set_elid('52', 'page', 'es', 857, 'en') #3 /{redacted}/wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-admin-post-ac in /{redacted}/wp-content/plugins/sitepress-multilingual-cms/classes/core-abstract-classes/class-wpml-set-language.php on line 32

May 21, 2019 at 8:32 am #3853237

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Montevideo (GMT-03:00)

Hi there,
Thank you very much for your message.

Could you tell me if this error also happen if you create a page under the minimal setup?

Regards,
Carlos

May 21, 2019 at 8:53 pm #3858845

aaronF-4

Hello,

Apparently I can't even save a new page in the default English language now. I went to Pages > Add New, gave it a title, hit Publish and received the same message:

Fatal error: Uncaught InvalidArgumentException: element_id and type do not match for element_id:869 the database contains post_attachment while this function was called with post_page in /home/aaronfisher/www/dytek/wp-content/plugins/sitepress-multilingual-cms/classes/core-abstract-classes/class-wpml-set-language.php:32 Stack trace: #0 /home/aaronfisher/www/dytek/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php(1489): WPML_Set_Language->set(869, 'post_page', false, 'en', NULL, true) #1 /home/aaronfisher/www/dytek/wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-post-translation.class.php(325): SitePress->set_element_language_details(869, 'post_page', false, 'en', NULL) #2 /home/aaronfisher/www/dytek/wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-post-translation.class.php(172): WPML_Post_Translation->maybe_set_elid(false, 'page', 'en', 869, NULL) #3 /home/aaronfisher/www/dytek/wp-content/plugins/sitepress-multilingual-cms/inc/post-translation/wpml-admin-post in /home/aaronfisher/www/dytek/wp-content/plugins/sitepress-multilingual-cms/classes/core-abstract-classes/class-wpml-set-language.php on line 32

May 22, 2019 at 9:48 am #3863919

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Montevideo (GMT-03:00)

Hi there,
Thank you very much for your message.

I applied some troubleshooting steps in the site and I was able to create a page in English titled 'test en'. Could you continue with the steps provided in my previous message?

Regards,
Carlos

May 22, 2019 at 6:00 pm #3868541

aaronF-4

Hello,

Thank you - I can now save pages again. Can I asked what you changed to fix this?

However I am not seeing the ACF fields translatable and finding some other issues (screenshot attached). I performed the following steps:

- Created a new ACF field group titled "WPML Test".
- Added two fields to the group, and set their Translation preferences to "Copy Once"
- Set the field group to show up for the "test en" page you created and saved the field group.
- Edited your "test en", populated the ACF fields, and saved the English version.
- Clicked the "Add Translation To Spanish" + button.
- Saved the Spanish version.

The ACF fields do not show up on the Spanish version page - I tried with and without the "WPML Translation Editor".

Also, for some reason a whole bunch of pages are now showing as duplicates (see screenshot).

May 23, 2019 at 9:54 am #3873173

Carlos Rojas
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Montevideo (GMT-03:00)

Hi there,

As the original issue is solved I kindly ask you to open a new ticket describing this new problem. This way we will be following the forum's rule of having one ticket per issue, it will also help future clients to find answers to similar problems.

Note: The steps I followed were: WPML -> Support -> Troubleshooting link -> Applied the troubleshooting steps pointed out in the attached image.

Thank you very much for your understanding!
Best regards,
Carlos

May 29, 2019 at 4:49 pm #3917561

aaronF-4

I will open up another ticket.