• Hi,

    i put language switcher into my post using <?php pll_the_languages();?> code. It display all flags from my languages settings and redirect to translated post or home page (if it isnt translated). I want to display only those flags(languages) which redirect to translated content. For example: I have post about fashion in German, English and Italian, but i dont have translations in French, Spanish etc. How can i display only German, English, Italian flags?

    Thank you for your answer and sorry for my english ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Chrystl

    (@chrystl)

    Hi
    You can do that thanks to ‘hide_if_no_translation’, see: https://polylang.pro/doc/function-reference/

    I need to show flags only for languages that have actual translation of current page, and if here is no translation except current language to do no show flags at all.

    I edited single.php in theme, and added this under the title.

    <?php

    $mParams = array( ‘show_flags’ => 1,’show_names’ => 0, ‘hide_if_empty’ => 1, ‘hide_if_no_translation’ => 1);
    pll_the_languages($mParams);

    ?>

    It shows flags for all languages on all posts regardless if there are translation articles or not. If there is translation in specific language flag link leads to translated page. If not, flag leads to home page for that language.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Language switcher in post – Display icons only for translated content’ is closed to new replies.