Due to the large volume of support requests you may experience longer wait until a supporter handles your request. We apologize for the inconvenience this causes. We encourage you to please search the forum for other support topics that may be helpful and to review our documentation. A supporter will respond to you as soon as possible.

[Resolved] Invalid argument supplied for foreach() when creating post translation

Home Support English Support [Resolved] Invalid argument supplied for foreach() when creating post translation

This topic contains 3 replies, has 2 voices, and was last updated by  sarah.n 1 year, 8 months ago. The support staff assigned to this topic is sarah.n.

Author Posts
Author Posts
January 23, 2013 at 10:32 pm #98829

Christian

Hi,

There seem to be a conflict between Portfolio Slideshow Pro and WPML. All the plugins are the latest versions.

When I create a translation for a post, a page, or a custom post, I get this error message:
Warning: Invalid argument supplied for foreach() in /nfs/c09/h03/mnt/136650/domains/cfp.christianthibault.com/html/wp-content/plugins/portfolio-slideshow-pro/inc/metabox/wordpress-creation-kit.php on line 917

At line 910 of this file and I found a function relating to WPML.
function wck_add_sync_translation_metabox(){
global $post;

if( isset( $_GET['lang'] ) ){

$has_wck_with_wpml_compatibility = false;
$custom_field_keys = get_post_custom_keys( $post->ID );
foreach( $custom_field_keys as $custom_field_key ){
$custom_field_key = explode( '_', $custom_field_key );
if( $custom_field_key[0] == 'wckwpml' ){
$has_wck_with_wpml_compatibility = true;
break;
}
}

if($has_wck_with_wpml_compatibility){
add_meta_box( 'wck_sync_translation', 'Syncronize WCK', array( &$this, 'wck_add_sync_box' ), $post->post_type, 'side', 'low' );
}

}
}

Could you please help me with this problem? Thank you.

January 24, 2013 at 7:07 am #98888

sarah.n
Forum moderator

Hello Christian,

Is line 917 this:

foreach( $custom_field_keys as $custom_field_key ){

If yes, then wrao that in an if statement like this:

if(!empty($custom_field_keys)){
foreach( $custom_field_keys as $custom_field_key ){
$custom_field_key = explode( '_', $custom_field_key );
if( $custom_field_key[0] == 'wckwpml' ){
$has_wck_with_wpml_compatibility = true;
break;
}
}
}

If this fixes it you will want to contact the plugin author about it so he can fix his function on his end as well.

January 24, 2013 at 1:41 pm #99027

Christian

Bonjour Sarah,

Yes, the code above fixed the issue. I will contact the plugin's author.
I thank you for your help.

Christian

January 25, 2013 at 10:18 am #99277

sarah.n
Forum moderator

Great! You are welcome!

You must be logged in to reply to this topic.