I created a child theme and it doesn’t work for some of the css files

You are calling your css files with wrong function like in following line of your code

wp_enqueue_style( 'parent-style', get_directory_directory_uri() . 'style.css' );

You are using get_directory_directory_uri() function to call files which is not event a function in wordpress.

Files must be called with one of the following two functions

  1. get_stylesheeet_directory_uri() : This function will search files in your active theme’s folder. By active theme means, theme that is activated by user from dashboard -> appearace -> theme. In your case child theme is active, so it will search file in your child theme folder.

  2. get_template_directory_uri() : This function will search files in your parent theme’s folder.

If your files are present in child theme’s folder then add this code in functions.php to call your css files

add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); 
function my_theme_enqueue_styles() { 
    wp_enqueue_style( 'parent-style', get_stylesheet_uri() );   //It will call your style.css file
    wp_enqueue_style( 'style1', get_stylesheeet_directory_uri() . '/rtl.css' );
    wp_enqueue_style( 'style2', get_stylesheeet_directory_uri() . '/assets/stylesheet/main.css' ); 
    wp_enqueue_style( 'style3', get_stylesheeet_directory_uri() . '/assets/stylesheet/bootstrap.css' ); 
}

In the above code parent-style, style1,style2,style1 are the user assign name and that name must be unique.
And in one line only one file will be called, so if you wanna call 4 files then you have to specify path of all files in different lines.

Note: If your files are present in Parent theme’s then you need to replace get_stylesheeet_directory_uri with get_template_directory_uri in above code.

For more detail read this article.

Leave a Comment