Problem:
I'm trying to change the post type of several posts. From Activities cpt to Destinations cpt. I tired to bulk change them using the Post Type Switcher plugin. I get a WPML related error, which I described here: https://wpml.org/forums/topic/wpml-error-during-changing-post-type-of-posts/
Solution:
In WordPress databases, all posts are stored in the posts table which is usually prefixed by wp_ (wp_posts table), the post type for each post is stored in the column post_type. Check more about the WordPress tables here https://codex.wordpress.org/Database_Description
That's what the "Post Type Switcher" plugin does, it changes the value of the column for each post in the source post type to the destination post type.
WPML uses the default WordPress databases for storing content and translations but uses some new tables to for storing relations/links between original and translated content. Shekhar has shared a link to WPML database documentation https://wpml.org/documentation/support/wpml-tables/
When you have changed the post types for your posts, WPML was not able to build an inconsistent state between the updated records in default WordPress table(wp_posts) and the translation links in WPML table(icl_translations, column element_type)
As there is no plugin that can switch the post type in WPML tables, you will have to change that in database level using SQL queries. This is an advanced level of technical skills, so If you are not comfortable with coding, consider hiring a developer one of our partners too, check here https://toolset.com/contractors/
I can also imagine another way, which will involve using a paid plugin(WP All Import/WP All Export). We can export all Activities and then import them as if they were Destinations. Check the following tutorials from WPML that explains how to export/import WPML translated contents.
The user fixed the issue in database level with the following SQL queries:
UPDATE `wp_posts` SET `post_type` = 'newcpt' WHERE `post_type` = 'oldcpt'; UPDATE `wp_icl_translations` SET `element_type` = 'post_newcpt' WHERE `element_type` = 'post_oldcpt'
Relevant Documentation:
https://wpml.org/documentation/support/wpml-tables/
https://wpml.org/documentation/related-projects/wpml-all-import-plugin-website-import-with-wpml/
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | - | - | 9:00 – 13:00 |
14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - | - | 14:00 – 18:00 |
Supporter timezone: Africa/Casablanca (GMT+01:00)
This topic contains 4 replies, has 2 voices.
Last updated by 4 years, 5 months ago.
Assisted by: Jamal.