skip to Main Content

In wordpress I try to work with the given syntax template_directory() for links.

If I use the full path from root directory it works.

$ptthlider_img_second = '/wp/wp-content/themes/theme_name/inc/img/front_slider/slide2.jpg';

My wished goal is to use template_directory for accessing the jpg.

$ptthlider_img_first = template_directory() . '/inc/img/front_slider/slide1.jpg';

Do you have any conclusions to assist me here?

Thanks and best regards,
Dennis

2

Answers


  1. You can use get_template_directory() as Daniel mentioned.

    Good to know:

    1. get_template_directory() will return the path of parent theme.
    2. get_stylesheet_directoty() will return the path of child theme if you are using one.
    3. They return path without trialing slashes.

    In addition there is a function get_bloginfo(‘template_directory’) and get_bloginfo(‘stylesheet_directory’), that can also be used for same purposes.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search