• Resolved vickkmartinez

    (@vickkmartinez)


    Hello. I created a shortcode to show the lang switcher. This is my code:

    add_shortcode('custom-language-switcher', 'trpc_custom_language_switcher', 10);
    function trpc_custom_language_switcher(){
        // Check whether TranslatePress can run on the current path or not. If the path is excluded from translation, trp_allow_tp_to_run will be false
        if ( apply_filters( 'trp_allow_tp_to_run', true ) ){
            $languages = trp_custom_language_switcher();
            $html = "<ul class='lang-list' data-no-translation>";
            foreach ($languages as $name => $item) {
                $html .= "<li>";
                $html .= "<a href='{$item['current_page_url']}'>";
                $html .= "<span>{$item['short_language_name']}</span></a></li>";
            }
            $html .= "</ul>";
            return $html;
        }
    }

    I want to show only the opposite lang (Hide the current lang). Is it possible? thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey there,

    Thanks for reaching out to us!

    We have this implemented as an option in our Advanced Settings. You can check this here.

    Thread Starter vickkmartinez

    (@vickkmartinez)

    Is not possible to add it in a custom shortcode? Because when I add the shortcode in my code it has a crazy behaivour on hover and a lot of css i don’t want to have.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.