0

I have a custom dashboard plugin with one of the sections containing useful links. One of them should directly point to the documentation that comes with a template. This documentation is in the theme directory. Now I've tried different ways to get the path using for example:

<?php get_theme_root_uri(); ?>/mytheme/documentation/index.html

or

<?php get_template_directory_uri() ?>/documentation/index.html

but it outputs a URL to the homepage (http://127.0.0.1/documentation/index.html) instead of full path to this file. Any advice?

  • 2
    Don't you want to echo that? – tfrommen Jan 23 '14 at 9:42
  • @tf damn.... I behaved like a total noob :/ Really embarrassed. Of course it works now. – Borek Jan 23 '14 at 9:44
1

I suppose, you want it to be like that:

<?php echo get_stylesheet_directory_uri(); ?>/documentation/index.html
2

As per the codex, get_template_directory_uri() returns the url, rather than path. You want get_template_directory() (codex) or get_stylesheet_directory() (codex).

There is a subtle but important difference between get_template_directory() and get_stylesheet_directory(). As per the (codex):

In the case a child theme is being used, the absolute path to the parent theme directory will be returned [by get_template_directory()]. Use get_stylesheet_directory() to get the absolute path to the child theme directory.

  • Seems I misinterpreted "...instead of full path to this file". – Stephen Harris Jan 23 '14 at 9:46
  • 1
    I understood it like he wanted to include a link <a href=..., that's why I chose *_uri. If he wants to include the file etc., then you're right, of course. – tfrommen Jan 23 '14 at 9:47

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.