# Preview the Site in Right-to-Left Mode

> Lets administrators add ?wpide_rtl=1 to any URL to see the site and dashboard laid out right-to-left, so themes can be checked for Arabic or Hebrew without switching the site language.

- Type: PHP
- Runs: Run everywhere
- Category: [Multilingual](https://wpide.com/library/category/multilingual/)
- Tags: rtl, testing, preview
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/i18n-rtl-preview-toggle/

## Code

```php
add_action( 'init', function () {
    if ( empty( $_GET['wpide_rtl'] ) || ! current_user_can( 'manage_options' ) ) { // phpcs:ignore WordPress.Security.NonceVerification
        return;
    }

    global $wp_locale;

    if ( $wp_locale instanceof WP_Locale ) {
        $wp_locale->text_direction = 'rtl';
    }
} );

add_action( 'admin_bar_menu', function ( $bar ) {
    if ( empty( $_GET['wpide_rtl'] ) || ! current_user_can( 'manage_options' ) ) { // phpcs:ignore WordPress.Security.NonceVerification
        return;
    }

    $bar->add_node( array(
        'id'    => 'wpide-rtl',
        'title' => 'RTL preview: on',
        'href'  => remove_query_arg( 'wpide_rtl' ),
    ) );
}, 100 );
```

## Notes

Only affects the logged-in administrator making the request. Add ?wpide_rtl=0 or remove the parameter to go back.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Preview the Site in Right-to-Left Mode" 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/
