Skip Navigation

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

Problem: We are getting this error:
Error log is showing the following:
PHP Fatal error: Uncaught InvalidArgumentException: element_id and type do not match for element_id:7283 the database contains post_page while this function was called with post_attachment in xxxx/content/plugins/sitepress-multilingual-cms/classes/core-abstract-classes/class-wpml-set-language.php:32\nStack trace:\n#0 xxxx/content/plugins/sitepress-multilingual-cms/sitepress.class.php(1497): WPML_Set_Language->set('7283', 'post_attachment', false, 'en', NULL, true)\n#1 xxxx/content/plugins/sitepress-multilingual-cms/classes/media/duplication/class-wpml-media-attachments-duplication.php(1016): SitePress->set_element_language_details('7283', 'post_attachment', false, 'en')\n#2 xxxx/wordpress/wp-includes/class-wp-hook.php(286): WPML_Media_Attachments_Duplication->batch_set_initial_language('')\n#3 xxxx/wordpress/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array)\n#4 xxxx/wordpress/ in xxxx/content/plugins/sitepress-multilingual-cms/classes/core-abstract-classes/class-wpml-set-language.php on line 32, referer

Solution: In this case the fastest way to solve the issue is by following this steps:
- Create a full backup of the site.
- Connect to the database -> in the wp_posts table delete the row with element ID = 7283
- Double check if the issue persists.
- Repeat this process if the error message appears again with another ID.

Note: Please don't forget to create a full backup of the site because if something goes wrong you will have to restore it.

Relevant Documentation:

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 topic contains 8 replies, has 2 voices.

Last updated by Carlos Rojas 4 years, 9 months ago.

Assisted by: Carlos Rojas.

Author Posts
February 5, 2020 at 9:04 pm #5434305

Jeremy

Tell us what you are trying to do?

Run Media Translation

Is there any documentation that you are following?

Reading WPML forums

What is the link to your site?

It's currently on our staging server:
hidden link

We can provide you with admin credentials.

Error log is showing the following:
PHP Fatal error: Uncaught InvalidArgumentException: element_id and type do not match for element_id:7283 the database contains post_page while this function was called with post_attachment in xxxx/content/plugins/sitepress-multilingual-cms/classes/core-abstract-classes/class-wpml-set-language.php:32\nStack trace:\n#0 xxxx/content/plugins/sitepress-multilingual-cms/sitepress.class.php(1497): WPML_Set_Language->set('7283', 'post_attachment', false, 'en', NULL, true)\n#1 xxxx/content/plugins/sitepress-multilingual-cms/classes/media/duplication/class-wpml-media-attachments-duplication.php(1016): SitePress->set_element_language_details('7283', 'post_attachment', false, 'en')\n#2 xxxx/wordpress/wp-includes/class-wp-hook.php(286): WPML_Media_Attachments_Duplication->batch_set_initial_language('')\n#3 xxxx/wordpress/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array)\n#4 xxxx/wordpress/ in xxxx/content/plugins/sitepress-multilingual-cms/classes/core-abstract-classes/class-wpml-set-language.php on line 32, referer: hidden link

We've seen others have a similar issue but we're not clear on how to resolve it.

We tried doing the following:

- Clear the cache in WPML
- Remove ghost entries from the translation tables
- Fix element_type collation
- Set language information

The last one would get stuck.

Please help.

February 6, 2020 at 2:54 pm #5440065

Carlos Rojas
Supporter

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

Timezone: Europe/Madrid (GMT+01:00)

Hello,
Thank you for contacting WPML support.

In this case the fastest way to solve the issue is by following this steps:
- Create a full backup of the site.
- Connect to the database -> in the wp_posts table delete the row with element ID = 7283
- Double check if the issue persists.
- Repeat this process if the error message appears again with another ID.

Note: Please don't forget to create a full backup of the site because if something goes wrong you will have to restore it.

Could you tell me if the issue is solved?

Kind regards,
Carlos

February 6, 2020 at 7:15 pm #5441945

Jeremy

Thank you for your response.

Actually, what might have happened is we attempted to convert latin1_swedish collation to utf8mb4_unicode_ci and something went wrong. We used another method to convert the tables (via phpmyadmin) and Running the Media Translations seems to work fine now. No more error.

But now we're dealing with another issue. Some of the images aren't showing up.

English Homepage: hidden link
Translated Homepage: hidden link

Some images are working, and some aren't. The images that ARE working are getting pulled using get_the_post_thumbnail_url() function. And images that AREN'T working are getting pulled with ACF function get_field()

We have "Advanced Custom Fields Multilingual" plugin installed. So we suspect something is wrong with WPML's settings.

Thank you

February 6, 2020 at 7:21 pm #5441955

Carlos Rojas
Supporter

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

Timezone: Europe/Madrid (GMT+01:00)

Hi,
I'm happy to hear that the original issue is solved 🙂

In this case the images that aren't appearing on the site are custom fields created with ACF. Could you take a look at our documentation about ACF and WPML and double check if the configuration is correct?

In this link you will the most relevant documentation:
- https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/
- https://wpml.org/documentation/getting-started-guide/translating-custom-fields/

Regards,
Carlos

February 6, 2020 at 8:52 pm #5442271

Jeremy

Great, thank you, we'll review the two links thoroughly. At first glance we have noticed that we don't have "Custom Field Translation" section as demonstrated in this screenshot: https://wpml.org/wp-content/uploads/2019/02/Setting-the-custom-fields-transaltion-prefrrence-from-the-WPML-Settings-page.png (taken from https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/)

Also, we're experiencing issue with Featured Image not being duplicated when we create a new translation for one of the Post Types (it works just fine with another post type). We made sure that the Post Type is set to "Translatable - only show translated items" and then we ran "Media Translation" with all the checkboxes checked, but the Featured Image still wouldn't duplicate when we created a translation for the post. (We tried deleting and creating the translation, but no luck!)

Thank you for your help!

February 6, 2020 at 11:06 pm #5442795

Jeremy

Please disregard the first issue with "Custom Field Translation" section missing, we had to install the Translation Manager Addon to make it appear.

However, we're still having an issue with Featured Image not duplicating for a specific post type. As mentioned, it works with one post type but not another. Both Post Types are set to "Translate" in Settings, and we clicked "Media Translation" button with all checkboxes selected (after selecting Translate for both post types).

FYI: We didn't install "Media Translation" addon as we're not planning to "translate" images, we just need them duplicated to other languages (whether it's a featured image or acf image field)

Thank you

February 7, 2020 at 10:17 am #5445439

Carlos Rojas
Supporter

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

Timezone: Europe/Madrid (GMT+01:00)

Hi,

In the case of the Featured Images, please follow this steps:
- Edit a Post -> On the right column under the Languages block there is an option to 'Duplicate the featured image' -> Check this option -> Save the post and update the translation.

Could you tell me if the issue disappeared?

Regards,
Carlos

February 10, 2020 at 6:19 pm #5464059

Carlos Rojas
Supporter

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

Timezone: Europe/Madrid (GMT+01:00)

Hi there,

I'm glad to hear that the issue is solved 🙂

Please don't hesitate to contact us if you need our help in the future with WPML. We will be more than happy to help.
Best regards,
Carlos