• I have a Child Theme but it doesen’t work.
    On my server i have a folder ‘spun-child’
    Inside this folder i have a field colled style.css like this:
    /*
    Theme Name: spun-child
    Description: Cambio estilo tema spun
    Author: Eloy Hernandez
    Template: spun
    */

    @import url(“../spun/style.css”);

    .site-title a{
    color: #d22929;
    }

    .main-navigation a {
    color:#705b56;
    display: block;
    text-decoration: none;
    }

    But it doesn’t work, the colors not change with the specifications of child theme.

    What’s the problem?

    Thanks a lot

Viewing 5 replies - 1 through 5 (of 5 total)
  • Impossible to say just from seeing your CSS. Try using Firefox with the Firebug add-on for this kind of CSS troubleshooting. Or use whatever developer tool is available in your web browser.

    One reason could be because the child theme’s style.css file isn’t being loaded. This may when the parent theme loads the stylesheet using wp_enqueue_style() instead of hardcoding it directly inside the <head> section.

    Try adding the following inside your functions.php file:

    add_action('wp_enqueue_scripts', 'spun_child_load_css' );
    function spun_child_load_css(){
        wp_enqueue_style('spun_child_style', get_stylesheet_uri());
    }

    This may when the parent theme loads the stylesheet using wp_enqueue_style() instead of hardcoding it directly inside the <head> section.

    I’m sorry but that’s rubbish. Using wp_enqueue_style() is the correct way to load stylesheets and will not interfere with the parent-child relationship or the child’s ability to over-write the parent’s CSS.

    @esmi,

    I’m not saying it’s the incorrect way. In fact, this is how I load stylesheets in my themes.

    But, my fault as I failed to elaborate how the parent theme could have messed it up. This would have happened if the parent theme referenced the stylesheet using:

    get_template_directory_uri() . '/style.css'

    instead of

    get_stylesheet_uri()

    So, if you child theme only has style.css file, then your child theme’s stylesheet would never load.

    That’s all I’m saying.

    And oh, would you agree that linking to the stylesheet in the <head> is how most themes do it? although it’s not the recommended way?

    I couldn’t answer for themes hosted elsewhere but I’m pretty sure that using wp_enqueue_style() is now mandatory for themes hosted on WPORG.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Problem with child Theme’ is closed to new replies.