How to Switch Out Video & Buttons with TranslatePress for WordPress Using Shortcode

TranslatePress is a powerful translation plugin when you want to cater to a multilingual audience. It automatically creates the language permalink structure, adds the language meta tags in the head area of your pages, and creates the Menu links to switch the language of every page. And if you don’t know the language you are switching to, you can pay for the Pro version and use Translate Press’ built in language translation features. For this tutorial I will be using Bing Translate.

There are many YouTube videos covering how to set up TranslatePress for WordPress, but there aren’t many showing you how to switch out video and HTML content.

This tutorial will cover TranslatePress setup, but it will also show you how to switch out anything else using shortcode.

Use this Index to jump ahead if you have already installed TranslatePress:

Step 1 – Setup TranslatePress

Step 2 – Translate

Step 3 – How to use TranslatePress Shortcode

Step 1 – Setup TranslatePress

Let’s say you have a Consulting business in the U.S. and you want to cater to English and Spanish speaking entrepreneurs. TranslatePress makes it easy to convert your WordPress website to a multilingual site.

    1. Start by going to Plugins > Add Plugin > and type “TranslatePress” into the Search field (one word). Choose Install Now and Activate.
    2. You should be taken to the TranslatePress setting, but if not, navigate to Settings > TranslatePress.
    3. The free version only allows one language, so I am going to set the second language to Spanish (Mexico) because I am in the U.S.Take note of the code here. We will be using this later in our shortcode.
    4. Scroll down the page and make sure you’ve checked the Menu Item option. You can also choose the Floating language section, but for this tutorial we’re going to focus on the menu.
    5. Now we can add the translation links to the Menu. Go to Appearance > Menus. From here we’re going to select Language Switcher and check Spanish and English, then Add to Menu. Position them where you want them in the menu and Save.
    6. Navigate back to Settings > TranslatePress.

Step 2 – Translate

It’s easy to translate the site from here.

    1. Select Translate Site and you will be taken to your Homepage where every section with accessible language can be translated, as well as image files ending in .jpg and .png. (Images ending in .webp cannot be switched out.) Simply hover over each section to access the pen (editing) tool and then translate that section. Here we are looking at “Content” on this site’s Homepage.
      Hovering over and selecting the edit tool, I can now add the Spanish translation under To Spanish. I’m using the free version of TranslatePress, so I’m going to open a new tab and go to https://www.bing.com/translator. From here I can enter “Content” on the left, which Bing Translator will auto-detect as English, and then I’ll select Spanish from the dropdown on the right. While this is not a perfect system (the only perfect system is to be fluent in that language), it’s enough to make sure your Spanish visitors can read the content on your website until you can refine your translation.
    2. From here you can trade out images and video, as long as they are links. For example, let’s say my logo contained English text and I wanted to trade it out for a logo with Spanish text. I would select the pen/edit icon and add the link from the Media folder to the To Spanish field.

Step 3 – How to use TranslatePress Shortcode

But what if I have an embedded video? Or what if I have an entire section that doesn’t fit into TranslatePress’ easy editing interface? Let’s fix this issue with shortcode!

In some cases embeds work better than links.

This website uses a video embed to explain tax issues.

And the site uses Elementor Page Builder, so we’re going to change this embed code to switch the Spanish version once the Spanish link is selected.

In this case we’ll drop the Shortcode Widget into the container. In the container you are using, copy and paste the following code:

				
					[trp_language language="en_US"] 
YOUR ENGLISH EMBED CODE HERE
[/trp_language]
[trp_language language="es_MX"] 
YOUR SPANISH EMBED CODE HERE
[/trp_language]
				
			

Replace YOUR EMBED CODE HERE with the full embed code from your YouTube or Vimeo video. Note the “code” we noticed when setting up TranslatePress?


This is the code we will use to tell WordPress what video to show depending on the language selected.

You can also do this with more content.

Let’s say you need a button embedded in a container that TranslatePress’ editor can’t get to. Try this:

				
					[trp_language language="en_US"] 
<a href="YOUR LINK HERE"><button style="background:#D44934;color:#fff;padding:10px 20px;border:none;" ><b>GET STARTED HERE</b></button></a>
[/trp_language]
[trp_language language="es_MX"] 
<a href="YOUR LINK HERE"><button style="background:#D44934;color:#fff;padding:10px 20px;border:none;"" ><b>EMPIEZA AQUÍ</b></button></a>
[/trp_language]
				
			

We’ve got some styling on our button, too, which is easy with html. 

Thank you for following this tutorial. For help with anything you can’t find an answer to, fill out the Contact Page here and let me know what you’d like to see.

Facebook
Twitter
LinkedIn

Click On Hotspots to View Specs

Header

Transparent header that switches to color on scroll with split menu

Phone Number

Click-to-call phone number

Form

Multistep form with BBB link to A+ rating

Services

Clear list of services

Testimonials

Elegant testimonial carousel

Call-to-Action

Call-to-Action button