I lost a lot of time for this problem, there were two alteatives to resolve it:
1. Using the shortcodes [polylang]:
// [polylang lang="en"]English[/polylang][polylang lang="sp"]Spanish[/polylang]
function polylang_shortcode($atts, $content = null)
{
if (empty($content))
retu '';
extract( shortcode_atts( array('lang' => ''), $atts ) );
if (empty($lang))
retu "<h3>You must specify 'lang' using shortcode: polylang</h3>";
retu ($lang == pll_current_language()) ? $content : '';
}
add_shortcode('polylang', 'polylang_shortcode');
This trick saved me many times, I think that the developers should integrate it.
Unfortunately in many fields of this theme I can't use shortcodes, so I could not use this trick.
2. Using php code, and I resolved in this way, so I had to edit the php file of theme section:
<?php
$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; // get current url
if (false !== strpos($url,'/en/')) { // if in url I find the string /en/
echo 'eng';
} elseif (false !== strpos($url,'/it/')) { // if in url I find the string /it/
echo 'ita';
}
?>
برچسب:
نویسنده: استخدام کار