Ov3rfly
Member
Posted 7 months ago #
If WPML Multilingual CMS plugin (more or less the standard plugin for multi-language WordPress sites) is installed, Post Type Switcher does not work as expected.
The post_type is changed in 'wp_posts' table but the post does not show up any more in admin-panel, not as old and not as new type.
Fix: When changing the post type, add a check if WPML is installed and if yes, adjust the type in a second table 'wp_icl_translations' as explained here:
if ( function_exists('icl_object_id') ) {
// adjust field 'element_type' in table 'wp_icl_translations'
// from 'post_OLDNAME' to 'post_NEWNAME'
// the post_id you look for is in column: 'element_id'
}
More about WPML-API here.
http://wordpress.org/extend/plugins/post-type-switcher/
http://wpml.org/
I'm responsible for WPML.
We're offering free WPML accounts for fellow plugin authors. If you're the author and want to work on this compatibility issue with us, please visit this page:
http://wpml.org/documentation/theme-compatibility/go-global-program/
Nowton
Member
Posted 6 months ago #
I just had this happen to me on my build location. How can I retrieve the missing posts?
fanchyfanch
Member
Posted 5 months ago #
Hi,
Thanks for the tip but don't you have the complete correct code to put exactly so the WPML plugin works properly ?
fanchyfanch
Member
Posted 4 months ago #
OK, it goes like this for those who search for a solution :
// in case of using the WPML plugin
if(function_exists('icl_object_id')){
// adjust field 'element_type' in table 'wp_icl_translations'
// from 'post_OLDNAME' to 'post_NEWNAME'
// the post_id you look for is in column: 'element_id'
if($post->post_type == 'revision'){
if(is_array($post->ancestors)){
$ID = $post->ancestors[0];
}
}else{
$ID = $post->ID;
}
$wpdb->update("{$wpdb->prefix}icl_translations", array('element_type' => 'post_' . $new_post_type_object->name), array('element_id' => $ID));
}