I have a rtl.css file for my theme. When I change the site language to Persian (from settings), rtl.css is loaded and works properly. But I want to keep it in English language and load rtl.css file. How I do it? When the language changes, what happens?
I have a rtl.css file for my theme. When I change the site language to Persian (from settings), rtl.css is loaded and works properly. But I want to keep it in English language and load rtl.css file. How I do it? When the language changes, what happens?
# 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' );
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 language, have you read the Codex page? There are automated tools that can help you flip your website.