# Edit Translations From the Admin Bar (WPML)

> Adds a "Translations" menu to the toolbar on single posts and pages with a link to edit each language version, so editors can hop between translations without searching.

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

## Code

```php
add_action( 'admin_bar_menu', function ( $bar ) {
    if ( is_admin() || ! is_singular() || ! defined( 'ICL_SITEPRESS_VERSION' ) ) {
        return;
    }

    $id = get_queried_object_id();

    if ( ! current_user_can( 'edit_post', $id ) ) {
        return;
    }

    $type         = apply_filters( 'wpml_element_type', get_post_type( $id ) );
    $trid         = apply_filters( 'wpml_element_trid', null, $id, $type );
    $translations = $trid ? (array) apply_filters( 'wpml_get_element_translations', null, $trid, $type ) : array();

    if ( count( $translations ) < 2 ) {
        return;
    }

    $bar->add_node( array( 'id' => 'wpide-wpml-tr', 'title' => esc_html__( 'Translations' ) ) );

    foreach ( $translations as $code => $item ) {
        $link = get_edit_post_link( (int) $item->element_id, 'raw' );
        if ( $link ) {
            $bar->add_node( array(
                'parent' => 'wpide-wpml-tr',
                'id'     => 'wpide-wpml-tr-' . sanitize_key( $code ),
                'title'  => esc_html( strtoupper( $code ) . ( (int) $item->element_id === $id ? ' (this page)' : '' ) ),
                'href'   => $link,
            ) );
        }
    }
}, 90 );
```

## Notes

Only languages that already have a translation are listed, and only for users who can edit the post.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Edit Translations From the Admin Bar (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/
