Question

Called the images in my theme as shown below

<img src="<?php bloginfo ('stylesheet_directory');?>/images/blogo.png" />

It worked perfectly until I installed a Child Theme. I had to change

<?php bloginfo ('stylesheet_directory');?>

to

<?php bloginfo ('template_directory');?>

Before it started working again. Just need help understanding why that happened. Thanks

Was it helpful?

Solution

stylesheet_directory is the directory that contains the main stylesheet in use (so if you have a child template then it would be the child directory. If not, it will be the template directory.

template_directory is the directory of your parent theme.

Look at the codex for more details

OTHER TIPS

Stylsheet directory links to the main stylesheet, and not the child theme( since the child theme may not contain the style.css by default, it inherits the style.css of parent theme. So the parent path is called if you are using this).

So always use get_stylesheet_uri() or get_template_directory_uri() for these purpose.

Hope this clarifies you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top