Please make sure to update to WPML 4.3.6 and check our list of Known Issues before reporting

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Our next available supporter will start replying to tickets in about 0.67 hours from now. Thank you for your understanding.

This topic contains 5 replies, has 2 voices.

Last updated by sarah.n 7 years ago.

Assigned support staff: sarah.n.

Author Posts
November 29, 2012 at 10:03 am #87400

Sorin

How can i make this translatable so is dependent on the current language, now it jumps to the original site language

<span class="read-more"><a href="<?php echo get_permalink(17); ?>">Details</a></span>

November 29, 2012 at 10:14 am #87404

sarah.n
Supporter

Languages: English (English ) German (Deutsch )

Hello Sorin,

You can achieve this using the icl_object_id(ID, type, return_original_if_missing,language_code) function.

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

In your case this will be something like this:

<?php $icl_object_id = icl_object_id(17, 'post', true); ?>
<span class="read-more"><a href="<?php echo get_permalink($icl_object_id); ?>">Details</a></span>

Replace the "post" parameter in <?php $icl_object_id = icl_object_id(17, 'post', true); ?> if you are linking to a page/category etc accordingly. The parameters are explained in the above linked article.

Hope this helps.

November 29, 2012 at 10:17 am #87405

Sorin

I used get_permalink(icl_object_id(17, 'page', true)) , this is working now, but i still may need to translate "Details"

November 29, 2012 at 10:25 am #87410

sarah.n
Supporter

Languages: English (English ) German (Deutsch )

Hello Sorin,

Make sure you wrap it in a getText function like this: <?php _e('Details','your-theme-textdomain');?>

See: http://wpml.org/2009/05/wordpress-theme-localization/#wrapping_in_gettext_functions

November 29, 2012 at 10:59 am #87421

Sorin

awesome support

Thank you,
Sarah

November 29, 2012 at 1:09 pm #87457

sarah.n
Supporter

Languages: English (English ) German (Deutsch )

You are welcome!