1

I have created and used over a dozen Wordpress child themes for various websites. I have downloaded the themes from Wordpress. This time I wanted to use a theme outside of Wordpress' realm. I heard good things about Gridly, actually it was part of Lynda.com's presentation.

When I tried to create a child theme for Gridly, I approached it in the same manner. I set up the usual directory and css files with the correct info at the top. I imported all the original theme's style.css. I activated my new child theme.

Despite all of that I still can't use custom CSS. In fact, when I use Chromes Dev tools and inspect where an element is getting its styling from, it comes from the parent theme's stylesheets. When I inspect the header it calls for

<?php if ($gridly_color_scheme == 'dark') { ?>
    <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?    >/css/dark.css" /> 
<?php  } elseif ($gridly_color_scheme == 'custom') {  ?>
    <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/custom.css"/> 
<?php  } else {?>
     <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/light.css"/> 
<?php  } ?>

I have don't know if that get_template_directory_uri(); is getting the parent or child theme's uri.

Can anyone shed any light on this?

0

Use get_stylesheet_directory_uri() and get_stylesheet_directory() for Child Themes

Use get_template_directory_uri() and get_template_directory() for Parent Themes

Thus making your function:

<?php if ($gridly_color_scheme == 'dark') { ?>
    <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?    >/css/dark.css" /> 
<?php  } elseif ($gridly_color_scheme == 'custom') {  ?>
    <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/css/custom.css"/> 
<?php  } else {?>
     <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/light.css"/> 
<?php  } ?>

...subtle difference which can be easy to miss.

Helpful resources:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.