Quantcast
Viewing all articles
Browse latest Browse all 20145

Reply To: image title for different language by using WPML

hi guys,

I have already figured it out how to do that.

[code]
$customers = get_post_meta(get_the_ID(), 'wpcf-customers', false);
foreach ($customers as $customer) {
$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid = %s", $customer));
//get the id for the translated image media
$translated_attachment_id = icl_object_id($attachment_id, 'attachment', false, ICL_LANGUAGE_CODE);
$title = get_the_title($translated_attachment_id);
//show image with title
}
[/code]

reference: http://wpml.org/documentation/support/creating-multilingual-wordpress-themes/language-dependent-ids/

thanks!

ucheng


Viewing all articles
Browse latest Browse all 20145

Trending Articles