puikinsh / Unite-Theme

Customizable WordPress WooCommerce theme developed using Bootstrap 3 and Options Framework
http://colorlib.com/wp/unite
114 stars 89 forks source link

Child theme #2

Closed aiiddqd closed 9 years ago

aiiddqd commented 10 years ago

Hi! I create child theme from insctruction http://codex.wordpress.org/Child_Themes But theme not worked and view as original Bootstrap.

puikinsh commented 10 years ago

Did you include:

@import url("../unite/style.css");

or (if theme was taken directly from Github and folder names was not changed) in style.css?

@import url("../unite-master/style.css");

If this is not the case, please share your code you have used in style.css and maybe even website URL if it is on live website.

ooscarr commented 9 years ago

Codex recommends to not use @import. The following code in child's functions.php did work for me:

<?php
add_action( 'wp_enqueue_scripts', 'enqueue_child_theme_styles', PHP_INT_MAX);
function enqueue_child_theme_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}

Source: http://wordpress.stackexchange.com/questions/164059/child-theme-does-not-overwrite-parent-themes-style-css

puikinsh commented 9 years ago

@ooscarr

Your method is closer but still won't work for Unite theme because your solution makes Child Theme style.css to load BEFORE Parent Theme style.css. Which means that no custom CSS would be applied as Parent Theme style.css would be more dominant.

A better solution would be like this:

// Queue parent style followed by child/customized style
add_action( 'wp_enqueue_scripts', 'unite_enqueue_child_styles', PHP_INT_MAX);

function unite_enqueue_child_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    wp_dequeue_style('unite-style');
    wp_enqueue_style( 'child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array('parent-style')
    );
}