Documentation > Restrict by language > Conditional Shortcode Based on Language

Conditional Shortcode Based on Language

Browse Docs
Search Documentation

When building a multilingual website, you may sometimes need more control over what content appears in different languages. For example, you might want to show a promotion, display different legal text depending on language, or completely hide content in specific translations.

TranslatePress makes this possible using dedicated shortcodes that let you include or exclude content based on the active language. 

How to use the TranslatePress conditional shortcodes to display content based on language

There are two shortcodes available for restricting content by language:

  • ).

    The result can be seen in the following images. The first page is the default English version and the second one is the Spanish version of the same page.

    Display videos based on language

    You can use conditional shortcodes to display different video content for each language on your website.

    To do this, simply wrap each video block between two shortcode blocks for the target language. The first shortcode block will contain the start of our conditional shortcode (eg. ).

    The results can be seen in the following images. The first page displays the video in the default English version, and the second page displays the video in the Spanish version of the same page.

    ).

    The result can be seen in the following images. The first page is the default English version and the second one is the Spanish version of the same page.

    Another alternative to the TranslatePress conditional shortcode is the String Translation interface where you can access gettext strings (such as emails) and easily translate them from a list.

    TranslatePress Multilingual

    The best website localization service for WordPress websites. Manage everything from a visual interface.