Show opposite language in language switcher

1. In your Menu Language Switcher

Sometimes you want to show just the opposite flag(s) in your menu.

This comes in really handy on bilingual wesbites, where you want to see the other language name or flag in the menu, not the current language.

This is possible with a bit of CSS.

    • go to Appearance -> Menus -> Screen Options (top right corner) and make sure “CSS Classes is checked”
    • next, edit your language menu items, and add for each language a custom class: tp_en for English, tp_fr for French, etc. You won’t be needing the “Current Language” item.
    • now, you can go to WordPress -> Appearance -> Customize -> Additional CSS and add some custom CSS like:
.translatepress-en_US .tp_en, 
.translatepress-fr_FR .tp_fr
{ display: none; }
  • the “translatepress-en_US” CSS class is added automatically for each language to the body of your HTML page. It contains the locale, not the language slug (from the TranslatePress settings), that’s why it’s en_US and not just en.

Note: You’ll have to replace the language locales with your languages.

2. In your Language Switcher Shortcode

Another place where you want to display the opposite flag(s) could be in the language switcher shortcode. You can achieve this if you install the following plugin: Opposite Language Shortcode (1736 downloads)