2021-01-10 11:34:00

Related Docs

Do You Need Help or Expertise?

Is editing Source Code not Your Thing? Are you in a tight Time Schedule and need to deliver a fully scalable and safe solution fast to your Clients?

Maybe you want to incorporate the Software found on TukuToi unbranded and royalty free in your Clients Projects after customizing it as per your Projects requirements?

Or eventually you need some training on any WordPress Plugin, Theme or their creation and maintenance?

ShortCodeMake iFrames Multilingual

Make iFrames MultiLingual

By default iFrames are not multilingual because they are HTML code. but there’s a way to easily make them multilingual without too much hassle.


function my_embed( $atts ) {
	$a = shortcode_atts( array(
		'src' => 'default_url_goes_here',
	), $atts );

	$awesome_iframe='<iframe width="100%" height="300" scrolling="no" frameborder="no" allow="autoplay" src="' . $a[src] . '"></iframe>';
	return $awesome_iframe;
}
add_shortcode( 'custom_iframe', 'my_embed' );

The code goes into your active theme’s function.php file and can be used by adding the “src” parameter in the shortcode from the “src” parameter in the iframe code you want to use.

Example

If the iFrame looks like this:

<iframe width="100%" height="300" scrolling="no" frameborder="no" allow="autoplay" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/playlists/1075752043&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true">

The shortcode will look like this:

[custom_iframe src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/playlists/1075752043&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true"]

Now all you have to do is register the shortcode to be translated with WPML using this guide: https://wpml.org/documentation/support/language-configuration-files/#page-builder-content

It would end up looking like this and you can add it in WPML > Settings > Custom XML Configuration:

<wpml-config>
   <shortcodes>
        <shortcode>
            <tag>custom_iframe</tag>
            <attributes>
                <attribute>src</attribute>
            </attributes>
        </shortcode>
   </shortcodes>
</wpml-config>

And that’s it!

You can translate iFrames now.