• Hi guys how do i force another css files to load from child theme.
    i have another css in the parent theme in assets\css\shop.css
    this is what i currently have in my function.php in the child folder

    <?php
    
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style',get_stylesheet_directory_uri() . '/style.css',array('parent-style')
    );
    }// END ENQUEUE PARENT ACTION
    • This topic was modified 11 months, 4 weeks ago by tuanny87.
    • This topic was modified 11 months, 4 weeks ago by tuanny87.
    • This topic was modified 11 months, 4 weeks ago by tuanny87.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello @tuanny87

    You need to modify your code to call Only Child theme CSS files . you need to remove parent theme css call code like below :

    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
    wp_enqueue_style(
    		'child-style',
    		get_stylesheet_directory_uri() . '/style.css',
    		[
    			'child-theme-style',
    		],
    		'1.0.0'
    	);
    }
    Thread Starter tuanny87

    (@tuanny87)

    if i want to add in another css thats in the child folder in assets\css\shop.css is this correct?. i tried it and for the most part looks like it worked but its prioritizing some changes from the parent. how do i set it so it reads the child css last. or at least prioritizing it because if i delete the file in the parent then its works so im guessing its prioritizing the parent.

    <?php
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
    wp_enqueue_style(
    'child-style',
    get_stylesheet_directory_uri() . '/style.css',
    [
    'child-theme-style',
    ],
    '1.0.0'
    );
    wp_enqueue_style( 'shop', get_stylesheet_directory_uri() . '/assets/css/shop.css' );
    }
    // END ENQUEUE PARENT ACTION
    • This reply was modified 11 months, 4 weeks ago by tuanny87.
    • This reply was modified 11 months, 4 weeks ago by tuanny87.

    Hello ,

    Your code is ok , just need to modify this line , need to add this PHP_INT_MAX , i have tested and it is working fine.

    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles',PHP_INT_MAX );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘how to load other child theme css files’ is closed to new replies.