0

I have a rtl.css file for my theme. when i change site language to Persian (from settings), rtl.css loaded and work properly.But i want to keep in english lanuage and load rtl.css file. How i do it? when language change, what happens? please help me. Tnx a lot.

2 Answers 2

0
# if you want to enqueue your style in you theme, rtl or else

function theme_enqueue_scripts() {

    # enqueue style in your theme

    wp_register_style( 'rtl', get_template_directory_uri() . '/css/rtl.css', array(), '1.0.0' );
    wp_enqueue_style( 'rtl' );


}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_scripts' );

# if you need enqueue this, just if theme is rtl , copy this function

function theme_enqueue_scripts() {

    if ( is_rtl() ) {

        wp_register_style( 'rtl', get_template_directory_uri() . '/css/rtl.css', array(), '1.0.0' );
        wp_enqueue_style( 'rtl' );

    }


}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_scripts' );
1
  • Thanks. But i don't understand.Where state of above code? please explain step by step what i do exactly?. Thanks a lot.
    – Saeid M
    Jan 17, 2017 at 12:43
0

When you change the language, WordPress automatically loads the rtl.css. How that happens is explained here.

As to use rtl.css without switching to a rtl langauge, have you read the Codex page? There are automated tools that can help you flip your website.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.