I'm currently outputting the term id's for several languages on a page. How can I output the term names for each instead?
I've tried to use the get_term
function to specifically get the French name for the taxonomy term and it still comes out in English even though the ID is the French id.
Where am I going wrong?
<?php
$taxonomy = "categories";
$terms = get_terms( array(
'suppress_filters' => false,
'taxonomy' => $taxonomy,
'hide_empty' => false,
) );
if ($terms) {
foreach ($terms as $term ) { ?>
<p>
EN: <?php echo $english = icl_object_id($term->term_id,'categories',false,'en'); ?><br />
FR: <?php echo $french = icl_object_id($term->term_id,'categories',false,'fr'); ?><br />
DE: <?php echo $german = icl_object_id($term->term_id,'categories',false,'de'); ?><br />
IT: <?php echo $italian = icl_object_id($term->term_id,'categories',false,'it'); ?><br />
RU: <?php echo $russian = icl_object_id($term->term_id,'categories',false,'ru'); ?><br />
ES: <?php echo $spanish = icl_object_id($term->term_id,'categories',false,'es'); ?><br />
<?php echo get_term(icl_object_id($french, 'categories', false, 'fr'))->name; ?>
</p>
<?php }
}
?>
I'm using WPML.