Tagged: 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #51410
    sandra1970
    Participant

    Hello!

    I have created a responsive.css in my child theme (just copy-paste – not sure if I need to add an @import line). I understood from a thread in the kathmandu theme that I need to add some code to the child function.php file for it to work, but with the kathmandu example in hand, I cannot seem to figure it out.

    Can you help me do that?

    Thanks a million!

    Sandra

    #51425
    Sakin
    Keymaster

    @Sandra1970: For adventurous theme, if you want to remove the parent theme responsive css and add your own child theme responsive.css file. Then you need to add the following code in you child theme functions.php file.

    // Remove Parent theme responsive.css and adding new responsive.css in child theme 
    function adventurous_child_enqueue_scripts() {
        wp_dequeue_style( 'adventurous-responsive' );
        wp_enqueue_style( 'adventurous-child-responsive', get_stylesheet_directory_uri() . '/responsive.css' );
    }
    add_action( 'wp_enqueue_scripts', 'adventurous_child_enqueue_scripts', 11 );
    #51466
    sandra1970
    Participant

    It worked! Thank you so much!

    #51612
    Sakin
    Keymaster

    @Sandra1970: Thanks for your appreciation.

    #51685
    Ronel
    Member

    Hello

    I have a follow-up question to this:
    I only want to change a very small piece of the responsive css. Is it possible to somehow enqueue my responsive css file to load after the parent responsive css, so that I don’t have to copy the whole file?

    Regards,
    Ronel

    #51692
    Sakin
    Keymaster

    @Ronel: Best option is to copy the whole css from parent theme responsive.css and then add your custom below. As the code I gave you will remove the parent theme responsive.css and then add your child theme responsive.css

    But if you want to create new responsive.css in your child theme with only few css that you want to edit. Then you don’t need to remove parent theme css. You just need to add your child theme responsive.css by adding in the following code in your child theme functions.php file.

    // dding new responsive.css in child theme 
    function adventurous_child_enqueue_scripts() {
        wp_enqueue_style( 'adventurous-child-responsive', get_stylesheet_directory_uri() . '/responsive.css' );
    }
    add_action( 'wp_enqueue_scripts', 'adventurous_child_enqueue_scripts', 11 );
    #51693
    Ronel
    Member

    Oh, duh! Just don’t dequeue the parent file and enqueue the child file with priority 11.

    Don’t mind me, I’ve got it working.

    #51694
    Sakin
    Keymaster

    @Ronel: Yes you are right 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Responsive.css not active in child theme’ is closed to new replies.