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="https://wordpress.stackexchange.com/questions/107986/<?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: