I have a multilingual website, English (default) and Arabic, and also a parent theme and a child one.
Now, I want to load the CSS on this order:
- In English: Parent Style.css then Child Style.css
- In Arabic: Parent Style.css then Child Style.css then Parent RTL.css then Child RTL.css
Because I want always the Child css to be dominant on the parent css, and also the RTL to be dominant in RTL mode.
I have added this code:
<?php
add_action( 'wp_enqueue_scripts', 'theme__child_enqueue_styles' );
function theme__child_enqueue_styles() {
wp_enqueue_style( 'theme-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'theme-child-style', get_stylesheet_uri() );
}
function load_parent_rtl_css() {
wp_enqueue_style( 'parent_rtl', trailingslashit( get_template_directory_uri() ) . 'rtl.css' );
wp_enqueue_style( 'child-rtl', get_stylesheet_uri() );
}
if ( is_rtl() ):
add_action( 'wp_enqueue_scripts', 'load_parent_rtl_css', 10 );
endif;
?>
But unfortunately, some parent style.css codes are overriding the parent rtl.css.
What is the right way to do this?