WordPress.org

Ready to get started?Download WordPress

Forums

Function: link image to different url based on wmpl language (1 post)

  1. vDT_Media
    Member
    Posted 2 years ago #

    Hello,

    I have images on my homepage. The images and the url are hard coded in a php template of the homepage. But i have four languages (i make use of the wpml plugin) and the image is now always linked to one url (the main language).

    I wanted to change that, when the language is english the url have to go to a english page on my website. When the language is dutch the url have to be different.

    I wrote the following code but that's not working.

    function set_link() {
    	$code = ICL_LANGUAGE_CODE;
    	if ($code == "nl")
    		return "http://www.url.nl/wordpress/nl/page/";
    	else if ($code == "en")
    		return "http://www.url.nl/wordpress/en/page/";
    	else if ($code == "fr")
    		return "http://www.url.nl/wordpress/fr/page/";
    	else if ($code == "de")
    	return "http://www.url.nl/wordpress/de/page/";
    
    }

    I want to call the function somewhere else on te page like this:

    <a title= "titel" href="<? set_link() ?>"> <img src="<?=get_bloginfo('template_url')?>/images/img_1.jpg" alt="description" /> </a>

    Could anybody help me. Thanks in advance!

Topic Closed

This topic has been closed to new replies.

About this Topic