• I have just started with WordPress and I have a theme I would like to use. However, this theme is not child-theme compatible.

    I have found that in header.php the theme uses

    href="<?php bloginfo('template_directory'); ?>/style.css"

    for the link href where it should probably be using

    href="<?php bloginfo( 'stylesheet_url' ); ?>"

    for the link href (since that is how the twentyeleven theme does it).

    My question is does anyone know of anything else that I may need to look at in regards to this theme?

    Thanks,
    Jason

Viewing 1 replies (of 1 total)
  • Hi Jason,
    That is just fine.

    In the child theme’s stylesheet you import the parents styles before the changes.

    In the child themes style.css we might have:

    /*
    Theme Name: Twenty Eleven Child
    Template: twentyeleven
    */
    
    @import url("../twentyeleven/style.css");

    Lets look at these lines:
    Theme Name: Twenty Eleven Child
    This one is our child themes name

    Template: twentyeleven
    This one is the parent themes folder name

    @import url(“../twentyeleven/style.css”);
    This one tells WordPress to get all the styles from the parent before any of our changes

    So it the parent has:

    /* Links */
    a {
    	color: #1982d1;
    	text-decoration: none;
    }

    And we want to change the link color in our child theme

    /*
    Theme Name: Twenty Eleven Child
    Template: twentyeleven
    */
    
    @import url("../twentyeleven/style.css");
    
    /* Change Link Color */
    a {
    	color: #ccc;
    }

    The last style change will now be applied, we have imported the stylesheet from the parent in our child themes style.css so it will not load it again.

    Test your theme with a simple child theme, it should work ok!

    You can also copy the header.php to the child theme and change the code there to look in the chld themes folders if you want.

    HTH

    David

Viewing 1 replies (of 1 total)
  • The topic ‘How to make a theme child-theme compatible?’ is closed to new replies.