wpexplorer

WPML Shortcode

Oct 10th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. /***WPML Translation Shortcode****/
  2. if(! function_exists('wpex_wpml_lang_translate')) {
  3. function wpex_wpml_lang_translate( $atts, $content = null ) {
  4. extract(shortcode_atts(array(
  5. 'lang' => '',
  6. ), $atts));
  7.  
  8. $lang_active = ICL_LANGUAGE_CODE;
  9.  
  10. if($lang == $lang_active){
  11. return do_shortcode($content);
  12. }
  13. }
  14. add_shortcode('wpml_translate', 'wpex_wpml_lang_translate');
  15. }
  16.  
  17.  
  18. /* USAGE
  19. *
  20. *[wpml_translate lang=es]Hola[/wpml_translate]
  21. *[wpml_translate lang=en]Hello[/wpml_translate]
  22. *
  23. */
Advertisement
Add Comment
Please, Sign In to add comment