If you would like to talk about your project call (02) 4474 5861

When to use get_template_directory_uri or get_stylesheet_directory_uri in a custom WordPress theme

The use of get_template_directory_uri or get_stylesheet_directory_uri is based on if your custom WordPress theme is a stand along theme (parent) or a child theme.

WordPress Parent Theme

For example say you are wanting to refer to an image in your stand alone custom WordPress theme then you would refer to it by using ‘get_template_directory_uri’.

<img src="<?php echo get_template_directory_uri(); ?>/img/logo.jpg" />

WordPress Child Theme

Now if you refering to an image from with your child theme folder you would use ‘get_stylesheet_directory_uri’.

<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/logo.jpg" />

If you where to use ‘get_template_directory_uri’ within your child theme it would refer to the parent theme folder. The way you could make sense of ‘get_stylesheet_directory_uri’ is simply by the fact your child theme css file (stylesheet) must be within its folder structure.

So in short use get_template_directory_uri when you are creating a parent theme and get_stylesheet_directory_uri when creating a child theme.

WordPress Parent Theme – echo get_template_directory_uri()

WordPress Child Theme – echo get_stylesheet_directory_uri()

Instinctively creative & thoughtful strategies with result orientated outcomes

Visually communicating effectively with your potential & current customers adds to the good business experience.

BJ2DESIGN combines a wealth of design knowledge with creative business strategies to create result oriented work.

Read More About BJ2DESIGN

creative hand and tools