• did another little hack

    at the top of polylang.php, add a new action, let’s say in the template tags section
    add_action('show_current_language', array(&$this, 'show_current_language'));

    then add a new function at the bottom, let’s say after the_languages

    function show_current_language() {
    	global $curlang;
    	$curlang = $this->curlang->slug;
    }

    in your theme, you can put something like this in your header

    <?php
    	$curlang = "none";
    	do_action('show_kcurrent_language');
    ?>

    now you can return the slug name of your lang at any time, use it for if statements or to load a file, for example, you can put things like this in page.php
    <?php include("sidebar-".$kcurlang.".php"); ?>

    or

    <?php
    	if($curlang == "en") {
    		echo "<h3>Latest News</h3>";
    	}elseif($curlang == "fr") {
    		echo "<h3>Dernières Nouvelles</h3>";
    	}
    ?>

    only 1 problem, the $curlang doesnt seem to get set within the theme header (you cant use that if statement example, but it works fine in the other template files, index/page/single/category/etc)

    https://www.ads-software.com/extend/plugins/polylang/

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Polylang] return the current language as variable for your template’ is closed to new replies.