icl_link_to_element and icl_object_id

Example usage

ExamplePurposeProduced HTML
<?php icl_link_to_element(10); ?>Link to page 10 (support page)<a href=”/support/”>Support</a>
<?php icl_link_to_element(10,’post’,__(‘Get help’)); ?>Link to support page with an alternative link text<a href=”/support/”>Get help</a>
<?php icl_link_to_element(10,’post’,false, array(‘category’=>’products’,’priority’=>’high’); ?>Link to support page and add two arguments<a href=”/support/?category=products&amp;priority=high”>Support</a>
<?php icl_link_to_element(10,’post’,false,’priority’=>’high’,’faq’); ?>
<?php icl_link_to_element(3,’tag’); ?>Link to tag with ID 3 (our ‘News’ tag)<a href=”/tag/news/”>News</a>

 

icl_link_to_element 可以以自动生成对应翻译页面的链接,但是不能给链接加上 自己想要的 class 或者 id

可以使用这样的方法:

<a href=”<?php echo get_permalink(icl_object_id(338, ‘page’, true)) ?>”><?php echo get_the_title(‘338’); ?></a>