0

Apologies if this has been answered elsewhere, but I've had some trouble finding the solution via Google.

I've set up a parent theme and a child theme. Inside the parent theme I have a directory named img which contains a number of images I want to use in the child theme too.

The problem is, I can't seem to find the best way to reference an image from the parent theme whilst inside the child theme. Surely there is a particular way to reference the path dynamically?

Whilst in the child theme, using <?php bloginfo('template_directory'); ?>/img/ seems to look for the img folder inside the child theme, but I am looking to reference the img folder inside the parent folder.

Any help on this would be great!

1

You can use <?php get_template_directory_uri(); ?> to reference your parent theme folders.

From the WordPress codex:

In the event a child theme is being used, the parent theme directory URI will be returned...

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.