Created
October 10, 2013 20:19
-
-
Save wpexplorer/6924897 to your computer and use it in GitHub Desktop.
WPML Shortcode for WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/***WPML Translation Shortcode****/ | |
if(! function_exists('wpex_wpml_lang_translate')) { | |
function wpex_wpml_lang_translate( $atts, $content = null ) { | |
extract(shortcode_atts(array( | |
'lang' => '', | |
), $atts)); | |
$lang_active = ICL_LANGUAGE_CODE; | |
if($lang == $lang_active){ | |
return do_shortcode($content); | |
} | |
} | |
add_shortcode('wpml_translate', 'wpex_wpml_lang_translate'); | |
} | |
/* USAGE | |
* | |
*[wpml_translate lang=es]Hola[/wpml_translate] | |
*[wpml_translate lang=en]Hello[/wpml_translate] | |
* | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment