 Daan
|
I have a custom post type that has meta data that contains an array.
When I duplicate the post for another language, the custom post meta data is duplicated as a string (double serialized). So when retrieving the meta, I get back a string instead of the (deserialized) array.
I solved it temporarily like this:
<pre>
$packageId = icl_object_id( get_the_ID(), 'package', true );
$packageIncludes = get_post_meta( $packageId, 'package_meta', true );
$packageIncludes = maybe_unserialize( $packageIncludes );
</pre>
|
 Harshad
|
Hello Daan,
Thanks for sharing this, I will try to reproduce the same at my end creating a custom post type.
Regards,
Harshad
|
 Marcin
|
I've run into the same problem. It seems that more flexible solution is to modify translation-management.class.php, function make_duplicate, just below the comment //copy custom fields. Get_post_custom used here returns serialized data, so one should change:
add_post_meta($id, $key, $value);
to
add_post_meta($id, $key, maybe_unserialize(stripslashes($value)));
Works for me.
Best regards
Marcin
|
 Paul
|
Hello,
same problem here.
2 months for solving this issue is too much guyz.
I had to make two fixes so far.
First, the same as Marcin.
Second, in sitepress.class.php, in the "update_post_meta" function hook, lines 2973-2978 :
if($original_id == $object_id){
foreach($translations as $t){
if(!$t->original){
update_post_meta($t->element_id, $meta_key, maybe_unserialize($_meta_value) );
}
}
}
I had to maybe_unserialize the meta_value before adding it to the translations/duplicate to prevent double serialization.
I hope this will be useful for some of us.
|