So, I tried to build a child theme to well-known wp theme “shapely”, but struggled with weird problem. When I activated my child theme, parent themes styles loaded in order that didn’t work. I needed to load bootstrap-style earlier and shapely’s native stylesheet after it, but somehow wordpress changed the order. Finally I had success with this hack:
function my_theme_enqueue_parent_styles() {
wp_enqueue_style( 'shapely-style', get_template_directory_uri() . '/style.css' );
}
function my_theme_enqueue_child_styles(){
wp_enqueue_style( 'shapely-child', get_stylesheet_directory_uri() . '/style.css');
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_parent_styles', 10 );
add_action( 'wp_enqueue_scripts', function(){ wp_dequeue_style('shapely-style');} );
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_child_styles', 20 );
This code uses add_action() priority option and also wp_dequeue_style function.
Thanks to stackexchange and to codex