# Translatable Text Shortcode for WPML

> Adds a [wpide_t name="..."]Text[/wpide_t] shortcode that registers its text in WPML String Translation and shows the translation, ideal for short phrases in widgets, footers and page builder text.

- Type: PHP
- Runs: Run everywhere
- Category: [Multilingual](https://wpide.com/library/category/multilingual/)
- Tags: wpml, string-translation, shortcode
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/wpml-string-shortcode/

## Code

```php
add_shortcode( 'wpide_t', function ( $atts, $content = '' ) {
    $atts = shortcode_atts( array( 'name' => '' ), $atts, 'wpide_t' );
    $name = sanitize_text_field( $atts['name'] );
    $text = trim( (string) $content );

    if ( '' === $name || '' === $text || ! defined( 'ICL_SITEPRESS_VERSION' ) ) {
        return do_shortcode( $text );
    }

    if ( current_user_can( 'manage_options' ) ) {
        do_action( 'wpml_register_single_string', 'Shortcode text', $name, $text );
    }

    return do_shortcode( (string) apply_filters( 'wpml_translate_single_string', $text, 'Shortcode text', $name ) );
} );
```

## Notes

Give every phrase a unique name. Strings register the first time an administrator views a page that uses them.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Translatable Text Shortcode for WPML" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
