WordPress.org

Support

Support » Plugins and Hacks » Post Type Switcher bug with WPML

Post Type Switcher bug with WPML

  • 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/

    Home

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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:

    Go-Global Program

    I just had this happen to me on my build location. How can I retrieve the missing posts?

    Hi,

    Thanks for the tip but don’t you have the complete correct code to put exactly so the WPML plugin works properly ?

    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));
    }

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Post Type Switcher bug with WPML’ is closed to new replies.