Polylang shortcode (like qTranslate) for theme options and text
-
Hi,
qTranslate is based on shortcodes to differentiate between the languages.
The only places I found this need in Polylang is in theme options strings.
Right now I need it for Craft theme. There are texts in home page and there is no other way to have them per language without changing the theme.Anyway, I wrote the shortcode:
// [polylang lang="en"]English[/polylang][polylang lang="sp"]Spanish[/polylang] function polylang_shortcode($atts, $content = null) { if (empty($content)) return ''; extract( shortcode_atts( array('lang' => ''), $atts ) ); if (empty($lang)) return "<h3>You must specify 'lang' using shortcode: polylang</h3>"; return ($lang == pll_current_language()) ? $content : ''; } add_shortcode('polylang', 'polylang_shortcode');
enjoy,
Ronny
- The topic ‘Polylang shortcode (like qTranslate) for theme options and text’ is closed to new replies.