Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Since I posted on their forum and I didn't got any answer, here I am, asking the same question again. So:

I made a script that add the posibility to add an image and change the order for the terms of a custom taxonomy (called itinerary).

So i use this way of getting each term, one by one (there are only up to 10 terms, so i don't think will be any performance penalties):

$term = get_term_by('id', $itinerary_id, 'itinerary' );

then get the image, description, url and so on.

The problem i have, however, is that i must have multilanguage content in a way that keeps the custom order AND custom image, so the site admin doesn't have to add images for each language (10terms * 6 languages * other images every week doesn't sound like fun!)

I tried to dig a little into WPML sql tables but I didn't found anything that relates to both (i'm playing now only with 2 languages, english and italian) languages

So i was wondering if there is something like get_translated_term()?

Thanks!

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Actually there is already in their API something for this:

icl_object_id(ID, custom_taxonomy_name, return_original_if_missing,language_code)

Works like a charm.

More read on this : Language Dependent IDs

share|improve this answer
    
This answer should be selected as correct answer –  Sisir Apr 9 at 19:26
add comment

I know this is an old post and my answer will thus primarily be for the googlers out there (how I got here).

I liked the idea of being able to just using a function like get_translated_term() as proposed above. So I wrote it (put in your functions.php):

function get_translated_term($term_id, $taxonomy, $language) {

    $translated_term_id = icl_object_id($term_id, $taxonomy, true, $language);

    $translated_term_object = get_term_by('id', $translated_term_id, $taxonomy);

    return $translated_term_object->name;
}

Then on any given place in your theme you can call the function as follows:

echo get_translated_term($term_id, 'taxonomy name', ICL_LANGUAGE_CODE);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.