Links to different social profiles depending the languaje in WordPress with WPML

If you have a blog or Website in different languages like this, may be, you could want to change the links of the social icons for different profiles depending the languaje which is selected. In this post I explain how to make an small change in the Theme to get a different link for the same icon.


In this case I am using WPML plugin to implementing a multilingual site. This plugin uses “ICL_LANGUAGE_CODE” constant to identify the language which the content is showing in. I am going to insert a If-Else statement in PHP¬† according to discriminate the links of different profiles.

Firstly, we have to find the code which shows the icons to social network and links in the Theme of WordPress. Over the icon, right button, chose “Inspect element” and identify the HTML code like in the image.



After that, find the file of the Theme where that code is. There are many ways and utilities, in my case, I have chosen Notepad++. (Find menu – find in files).



When the code has been found in the file, insert an If-Else PHP statement to separate  the links depending on the case.




Original code:

<?php echo esc_url($accesspresslite_settings['accesspresslite_twitter']); ?>

Inserted code:

	// Modification for different Twitter link in different languages
	if (ICL_LANGUAGE_CODE == 'eu') {
	echo "";
	} elseif (ICL_LANGUAGE_CODE == 'es') {
	echo "";
	} else {
	echo esc_url($accesspresslite_settings['accesspresslite_twitter']);