Skip to content
Public Ticket #32504

RTL Issue

Conversation thread

PenciDesign replied

Staff Reply

Hi,

If you want to do that, please use child theme.

You can use plugin Customizer Export/Import to move customization data to child theme.

And copy the codes in rtl.css and add more that codes to style.css file of child theme filesmile.png

Best Regards,

PenciDesign

luvrockz replied

Customer Reply

is there any way to do this without editing a theme file? so that i dont have to remember what i edited when updating the theme

PenciDesign replied

Staff Reply

Hi,

This issue caused by you've moved all that code to plugin. That make RTL style enque above the theme style and make the site broken. I just change the code on your plugin to:

\
// change backend to LTR and frontend to RTL\
add_filter('body_class', 'penci_set_frontend_locale_class');\
function penci_set_frontend_locale_class($classes) {\
      if( ! is_admin() ) {\
    $classes[] = 'rtl';\
    }\
    return $classes;\
}\
add_filter( 'language_attributes', 'penci_add_language_attributes' );\
function penci_add_language_attributes($output) {\
    if( ! is_admin() ) {\
    return  $output = 'dir="rtl" ' . $output;\
    }\
   return $output;\
}\
// change backend to LTR and frontend to RTL\

And add more this code to functions.php file - check this image: http://prntscr.com/l77ia6

Best Regards,

PenciDesign

luvrockz replied

Customer Reply

its breaking some part of the frontend now..

PenciDesign replied

Staff Reply

Hi,

If so, please try replace the code I sent you before to this code:

\
add_filter('body_class', 'penci_set_frontend_locale_class');\
function penci_set_frontend_locale_class($classes) {\
      if( ! is_admin() ) {\
    $classes[] = 'rtl';\
    }\
    return $classes;\
}\
add_action( 'wp_enqueue_scripts', 'penci_load_rtl_scripts' );\
function penci_load_rtl_scripts() {\
    if( ! is_admin() ) {\
    wp_enqueue_style( 'penci_style_rtl', get_stylesheet_directory_uri() . '/rtl.css', array(), '6.1' );\
    }\
}\
add_filter( 'language_attributes', 'penci_add_language_attributes' );\
function penci_add_language_attributes($output) {\
    if( ! is_admin() ) {\
    return  $output = 'dir="rtl" ' . $output;\
    }\
   return $output;\
}\

Best Regards,

PenciDesign

luvrockz replied

Customer Reply

right now im facing another issue. 

the language of front end is Arabic now.

I actually dont want it to be in arabic. just want it to be in RTL because ill be using a customer language.

so it should be in english but RTL;

PenciDesign replied

Staff Reply

Hi,

I've fixed it help you by change the code to:

\
add_filter( 'locale', 'penci_set_frontend_locale' );\
function penci_set_frontend_locale( $locale ) {\
    // check if you are in the Admin area\
    if( ! is_admin() ) {\
        // set LTR locale\
        $locale = 'ar';\
    }\
    return $locale;\
}\
add_filter('body_class', 'penci_set_frontend_locale_class');\
function penci_set_frontend_locale_class($classes) {\
      if( ! is_admin() ) {\
    $classes[] = 'rtl';\
    }\
    return $classes;\
}\
add_action( 'wp_enqueue_scripts', 'penci_load_rtl_scripts' );\
function penci_load_rtl_scripts() {\
    if( ! is_admin() ) {\
    wp_enqueue_style( 'penci_style_rtl', get_stylesheet_directory_uri() . '/rtl.css', array(), '6.1' );\
    }\
}\
add_filter( 'language_attributes', 'penci_add_language_attributes' );\
function penci_add_language_attributes($output) {\
    if( ! is_admin() ) {\
    return  $output = 'dir="rtl" ' . $output;\
    }\
   return $output;\
}\

Best Regards,

PenciDesign

luvrockz replied

Customer Reply

i this i fixed the issue by updating the code to this

\
add_filter( 'locale', 'penci_set_frontend_locale' );
function penci_set_frontend_locale( $locale ) {
    // check if you are in the Admin area
    if( ! is_admin() ) {
        // set LTR locale
        $locale = 'ar';
    }
    return $locale;
}
add_filter('body_class', 'penci_set_frontend_locale_class');
function penci_set_frontend_locale_class($classes) {
    $classes[] = 'rtl';
    
    return $classes;
}
add_action( 'wp_enqueue_scripts', 'penci_load_rtl_scripts' );
function penci_load_rtl_scripts() {
    if( ! is_admin() ) {
    wp_enqueue_style( 'penci_style_rtl', get_stylesheet_directory_uri() . '/rtl.css', array(), '6.1' );
    }
}
add_filter( 'language_attributes', 'penci_add_language_attributes' );
function penci_add_language_attributes($output) {
    if( ! is_admin() ) {
    return  'dir="rtl" ' . $output;
    }
}\

luvrockz replied

Customer Reply

hi i have tested the code. its making the front end the way i want, but its up the backend,

see attached image. also please login to site and check back end

PenciDesign replied

Staff Reply

Hi,

Please send me your admin url and admin account ( username and password  ) in a private reply. I will take it a look on this.

Best Regards,

PenciDesign

luvrockz replied

Customer Reply

hi, i think this will only allow me to switch a specific page. as my blog is a multi author blog, i want all admin pages to be in english and LTR.

PenciDesign replied

Staff Reply

Hi,

You can use this plugin to do that.

Best Regards,

PenciDesign

luvrockz started the conversation

Conversation Start

Hi, i would like to enable RTL mode in only front end of the site. 

im pasting this code in last line of functions.php but something else is overriding it.

\
if( ! is_admin() ) { // not admin area        // set RTL locale        $locale = 'ar';    }

Please kindly help me on this

Want to join this conversation or access attachments? Sign in first.