Okay
  Public Ticket #1437312
Give priority to Child Css
Closed

Comments

  •  3
    Pietro started the conversation

    Hi there,

    I know there's a theme function to upload custom CSS, but I wan't to use a .css file as it's more professional, fast and easy to use.

    I can't find a way to enque my child theme style after the parent's one.

    I've even tried 

    function dequeue_styles() {
    // this removes the original style
    wp_dequeue_style( 'style-css' );
    wp_deregister_style( 'style-css' );
    wp_dequeue_style( 'oxygen-main-css' );
    wp_deregister_style( 'oxygen-main-css' );
    }
    add_action( 'wp_enqueue_scripts', 'dequeue_styles', 10 );

    But they still stay there.

    Please help me out as i don't want use !important.

    Thanks

  • [deleted] replied

    Hi Pietro,

    By default, Child Theme will enqueue the style below oxygen.css and style.css of parent theme:


    (view large version)

    As you can see "1" is the Oxygen main style and then after it "2" loads.

    The child theme has the priority of enqueue set to 100:

    <?php
    /**
    * Oxygen WordPress Theme
    *
    * Laborator.co
    * www.laborator.co
    */

    // This will enqueue style.css of child theme
    function enqueue_childtheme_scripts() {
    wp_enqueue_style( 'oxygen-child', get_stylesheet_directory_uri() . '/style.css' );
    }

    add_action( 'wp_enqueue_scripts', 'enqueue_childtheme_scripts', 100 );

    So consider replacing it with this form.

    However if you want to dequeue oxygen.css entirely then you can use wp_dequeue_style( 'oxygen-main' )and that should do the trick.

  •  3
    Pietro replied

    Hi and thanks Arlind, 

    I was dequeueing incorrectly, calling it oxygen-main-css.

    Regards