Wasteland
Wasteland

Reputation: 5389

WP - child theme get the theme directory

I have an image folder in a child directory where some theme-related gfx is located. If I want to access it via:

<img src="<?php echo get_template_directory_uri();?>/assets/Logo.svg" />

It's trying to look for /assets in the parent theme directory.

How can I reference the child theme directory?

Upvotes: 1

Views: 2636

Answers (1)

Samvel Aleqsanyan
Samvel Aleqsanyan

Reputation: 2960

The function get_template_directory_uri always return the url of Parent Theme. Don't matter, where you called it.

To get the url of your Child Theme, you can use get_stylesheet_directory_uri(). So, your code will be:

<img src="<?php echo get_stylesheet_directory_uri();?>/assets/Logo.svg" />

Upvotes: 3

Related Questions