Skip to main content

I think you have to be a little careful because it depends on what you are trying to do.

If you are using a child theme get_template_directory();get_template_directory(); will still go to the parent theme. However get_stylesheet_directory();get_stylesheet_directory(); will go to the current theme, child or parent. Also, both these functions return absolute server paths.

If you wanted a fully formed URI, for links or images, you should use get_template_directory_uri();get_template_directory_uri(); or get_stylesheet_directory_uri();get_stylesheet_directory_uri(); using the correct one for the reasons stated.

Summary

I think you have to be a little careful because it depends on what you are trying to do.

If you are using a child theme get_template_directory(); will still go to the parent theme. However get_stylesheet_directory(); will go to the current theme, child or parent. Also, both these functions return absolute server paths.

If you wanted a fully formed URI, for links or images, you should use get_template_directory_uri(); or get_stylesheet_directory_uri(); using the correct one for the reasons stated.

Summary

I think you have to be a little careful because it depends on what you are trying to do.

If you are using a child theme get_template_directory(); will still go to the parent theme. However get_stylesheet_directory(); will go to the current theme, child or parent. Also, both these functions return absolute server paths.

If you wanted a fully formed URI, for links or images, you should use get_template_directory_uri(); or get_stylesheet_directory_uri(); using the correct one for the reasons stated.

Summary

summary and Codex links
Source Link
Chip Bennett
  • 55.1k
  • 8
  • 90
  • 170

I think you have to be a little careful because it depends on what you are trying to do.

If you are using a child theme get_template_directory(); will still go to the parent theme. However get_stylesheet_directory(); will go to the current theme, child or parent. Also, both these functions return absolute server paths.

If you wanted a fully formed URI, for links or images, you should use get_template_directory_uri(); or get_stylesheet_directory_uri(); using the correct one for the reasons stated.

Summary

I think you have to be a little careful because it depends on what you are trying to do.

If you are using a child theme get_template_directory(); will still go to the parent theme. However get_stylesheet_directory(); will go to the current theme, child or parent. Also, both these functions return absolute server paths.

If you wanted a fully formed URI, for links or images, you should use get_template_directory_uri(); or get_stylesheet_directory_uri(); using the correct one for the reasons stated.

I think you have to be a little careful because it depends on what you are trying to do.

If you are using a child theme get_template_directory(); will still go to the parent theme. However get_stylesheet_directory(); will go to the current theme, child or parent. Also, both these functions return absolute server paths.

If you wanted a fully formed URI, for links or images, you should use get_template_directory_uri(); or get_stylesheet_directory_uri(); using the correct one for the reasons stated.

Summary

Source Link
jw60660
  • 1.5k
  • 2
  • 14
  • 28

I think you have to be a little careful because it depends on what you are trying to do.

If you are using a child theme get_template_directory(); will still go to the parent theme. However get_stylesheet_directory(); will go to the current theme, child or parent. Also, both these functions return absolute server paths.

If you wanted a fully formed URI, for links or images, you should use get_template_directory_uri(); or get_stylesheet_directory_uri(); using the correct one for the reasons stated.