• Resolved d

    (@dnicinski)


    How can I code the switcher to show/hide in the sidebar? We need to code it directly in the template with a wrapper around it. Not in the widgets. Can you help me finish this IF Else statement please?

    <?php
    if ( ????? ) { // if translation exists show language switcher

    if (get_locale() == ‘en_US’) {
    echo ‘<section class=”widget widget-related-content custom-sidebar”><h3>Translation</h3>

      ‘;
      } else {
      echo ‘<section class=”widget widget-related-content custom-sidebar”><h3>’.pll__(‘Translation’).'</h3>
      ‘;
      }
      pll_the_languages(
      array(‘show_flags’=>1,
      ‘show_names’=>1,
      ‘hide_current’=> 1,
      ‘hide_if_empty’ => 1,
      ‘force_home’ => 0,
      ‘hide_if_no_translation’ => 1));
      echo ‘

    </section>’;

    } else {

    // DO NOT SHOW ANYTHING

    }

    ?>

Viewing 1 replies (of 1 total)
  • Thread Starter d

    (@dnicinski)

    I figured it out…

    <?php
    $languages = pll_the_languages(array(
    ‘show_flags’=> 1,
    ‘raw’ => 1,
    ‘hide_if_no_translation’ => 1,
    ‘show_names’=> 1,
    ‘hide_current’=> 1,
    ‘hide_if_empty’ => 1,
    ‘force_home’ => 0,
    ‘hide_if_no_translation’ => 1
    ));
    if ($languages == true ){
    if (get_locale() == ‘en_US’) {
    echo ‘<section class=”widget widget-related-content custom-sidebar”><h3>Translation</h3>

      ‘;
      } else {
      echo ‘<section class=”widget widget-related-content custom-sidebar”><h3>’.pll__(‘Translation’).'</h3>

    </section>’;
    };
    ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Language Swtcher – Show /Hide in Sidebar’ is closed to new replies.