Join the Soledad Facebook Users Group here
for Share, assistance, discussion, and Updates related to Soledad WordPress Theme.

If you can't create a new ticket - you can send us an email via our contact form and we will get back to you.

Okay
  Public Ticket #1746237
RTL Issue
Closed

Comments

  • luvrockz started the conversation

    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

  •  2,700
    PenciDesign replied

    Hi,

    You can use this plugin to do that.


    Best Regards,

    PenciDesign

  • luvrockz replied

    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.

  •  2,700
    PenciDesign replied

    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 privately
  •   PenciDesign replied privately
  • luvrockz replied

    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

  • luvrockz replied

    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;
        }
    }
  •  2,700
    PenciDesign replied

    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

    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;

  •  2,700
    PenciDesign replied

    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

    its breaking some part of the frontend now..

  •  2,700
    PenciDesign replied

    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

    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

  •  2,700
    PenciDesign replied

    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 file


    Best Regards,

    PenciDesign