Disabling RTL and WPML

I am having trouble with the WPML and X theme RTL function.

I use WPML and for the arabic translation it does an RTL across the whole theme, menu´s and homepage everything basically. How do I disable this?

I’ve found several topics on how to enable it but nothing on how to disable this, is there an CSS command I can use to disable this?

Hey @sassi80,

Please check with WPML support if they have a feature to set the locale to English even if the language is Arabic.

It is only natural for themes and plugins that support RTL to load the RTL CSS when the locale or Site Language is Arabic or technically when is_rtl is true. That operation is automatic and that is a standard. There’s no option to disable it. Also make sure your Site Language in Settings > General is set to English. Beyond that, it is WPML that is responsible as that is the plugin that switches the locale.

The last option you can try is filtering the locale yourself. Here’s a third-party guide: https://mattwatson.codes/articles/changing-wordpress-site-language-locale-dynamically. Please just note that we are not responsible for issues that might arise from the use and enhancement of custom code.

Hope that helps.

WPMl has the following 2 solutions:


with the following CSS code:

html {
  direction:ltr !important;
}

or add this in the functions.php

add_filter( 'body_class', 'remove_rtl_btag' );
function remove_rtl_btag($classes) {
    if( is_rtl() ) {
        $key = array_search( 'rtl', $classes );
        unset($classes[$key]);
    }
 
    return $classes;
}

The one with the CSS code works only for the body, it does not do this with the navigation and header and buttons etc. and the one with the PHP code gives back error. Please advice

Hello @sassi80,

Please make sure that you have copied and pasted the PHP code correctly.

add_filter( 'body_class', 'remove_rtl_btag' );
function remove_rtl_btag($classes) {
    if( is_rtl() ) {
        $key = array_search( 'rtl', $classes );
        unset($classes[$key]);
    }
 
    return $classes;
}

In most case, (especially in Windows machine) the quotes gets screwed up displaying a different quotation marks which causing the error. Please double check the quotes.

@RueNel Thanks mate that did the trick, I think I copied it correct in the first place but my dumb ass pasted in the style part of the theme child. 101 mistake when you feel you’ve become familiar with the theme that you stop checking basic things… like am I pasting this in the correct place hahaha.

Thanks for your help guys! first time I needed to post something in years and got the proper help within 24 hours. Awesome!

You’re always welcome @sassi80.

Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.