• Resolved codeexplorer1

    (@codeexplorer1)


    Hi,

    Can I place language switcher anywhere with shortcode? as Menu is not working on the mobile and the solution provided in another thread is also not working.

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Alex Gor

    (@alexgff)

    To create a language switcher you can use the sample code from
    https://github.com/WPGlobus/WPGlobus/blob/develop/language-switcher-sample.php
    And place it where you want or wrap it in a shortcode.

    Thread Starter codeexplorer1

    (@codeexplorer1)

    Thanks for the guidance. It worked. The remaining aspect is that instead of Language Code that I have configured in plugin. I am getting complete name of the language. Can you please suggest, how to overcome that?

    Plugin Contributor Alex Gor

    (@alexgff)

    Please paste the code snippet in question here.

    Thread Starter codeexplorer1

    (@codeexplorer1)

    <div class=”wpglobus-selector-box”> <?php

    /**
    * Filter that prevent using language that has draft status.
    * That works with module Publish from WPGlobus Plus add-on.
    */
    $enabled_languages = apply_filters( ‘wpglobus_extra_languages’, WPGlobus::Config()->enabled_languages, WPGlobus::Config()->language );

    foreach ( $enabled_languages as $language ):
    $url = null;
    $is_current = true;

    if ( $language != WPGlobus::Config()->language ) {
    $url = WPGlobus_Utils::localize_current_url( $language );
    $is_current = false;
    }

    $flag = ‘flags_url . WPGlobus::Config()->flag[ $language ].'” />’;
    $link = $flag . ‘ ‘ . WPGlobus::Config()->en_language_name[$language] . ‘   ‘;

    printf( ‘%s‘, ( empty( $url ) ? ” : ‘href=”‘ . esc_url( $url ) . ‘”‘ ), ( $is_current ? ‘class=”wpglobus-current-language”‘ : ” ), $link );

    endforeach; ?>

    </div>

    Plugin Contributor Alex Gor

    (@alexgff)

    You can change
    WPGlobus::Config()->en_language_name[$language]
    to
    $language

    Thread Starter codeexplorer1

    (@codeexplorer1)

    Thanks.

    Plugin Contributor Alex Gor

    (@alexgff)

    Please add a review to this page

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Shortcode to place language switcher anywhere’ is closed to new replies.