How to load rtl.css file without changing lanuage to persian in wordpress?

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.

Topic multi-language Wordpress

Category Web


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.


# 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' );

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.