Title: get_template_directory_uri
Last modified: August 31, 2016

---

# get_template_directory_uri

 *  Resolved [DanielKYantis](https://wordpress.org/support/users/danielkyantis/)
 * (@danielkyantis)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/get_template_directory_uri/)
 * `<?php echo esc_url( get_template_directory_uri() ); ?>`
    not returning proper
   value or i’m just doing something wrong!
 * I installed a menu and realized later that it doesn’t work on the portfolio and
   testimonial pages. It works everywhere else just not there.
 * I’ve played with various ways to reference the css and js files but it seems 
   that `<?php echo esc_url( get_template_directory_uri() ); ?>` returns different
   values than expected.
 * they way I have it now is
    `<link rel="stylesheet" type="text/css" href="wp-content/
   menu_files/swimbi-b.css"/>` tis works on all pages except testimonial and portfolio
   pages…
 * i’ve tried `<link rel="stylesheet" type="text/css" href="<?php echo esc_url( 
   get_template_directory_uri() ); ?>/menu_files/swimbi-b.css"/>` and this also 
   works on most pages except testimonials and portfolio pages.
 * I’ve looked and the code generated by the php and it seems that testimonial and
   portfolio pages handle <?php echo esc_url( get_template_directory_uri() ); ?>
   differently than other pages.
 * on testimonial pages the url changes to:
    [http://1weddingdj.com/testimonial/wp-content/menu_files/swimbi.css](http://1weddingdj.com/testimonial/wp-content/menu_files/swimbi.css)
   and same for portfolio pages: [http://1weddingdj.com/portfolio/wp-content/menu_files/swimbi.css](http://1weddingdj.com/portfolio/wp-content/menu_files/swimbi.css)
 * on all other pages it’s :
    [http://1weddingdj.com/wp-content/menu_files/swimbi.css](http://1weddingdj.com/wp-content/menu_files/swimbi.css)
 * my temp solution is to create directories on root with those files…

Viewing 12 replies - 1 through 12 (of 12 total)

 *  Thread Starter [DanielKYantis](https://wordpress.org/support/users/danielkyantis/)
 * (@danielkyantis)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/get_template_directory_uri/#post-7417046)
 * however, after creating those directories i now get 404 and forbidden errors 
   for all testimonials and all portfolio. individual portfolio pages and testimonial
   pages still work.
 *  Thread Starter [DanielKYantis](https://wordpress.org/support/users/danielkyantis/)
 * (@danielkyantis)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/get_template_directory_uri/#post-7417052)
 * <?php echo esc_url( get_stylesheet_directory_uri() ); ?>
    seems to work better
   than my other option, but now the menu itself does not work with the images next
   to the menu items.
 * I’m not sure if the issue lies with wordpress or my menu.
 * I had to remove /testimonial & /portfolio directories because that seems to have
   messed up wordpress causing 404 errors.
 *  [Clarion Technologies](https://wordpress.org/support/users/clarionwpdeveloper/)
 * (@clarionwpdeveloper)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/get_template_directory_uri/#post-7417071)
 * Hello DanielKYantis,
 * Can you please try once by using below function to get template directory path
 *     ```
       <?php echo get_template_directory(); ?>
       ```
   
 * Thanks
 *  Thread Starter [DanielKYantis](https://wordpress.org/support/users/danielkyantis/)
 * (@danielkyantis)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/get_template_directory_uri/#post-7417109)
 * `<?php echo get_template_directory(); ?>`
    /homepages/7/xyz/htdocs/AustinWeddingDJs/
   wp-content/themes/zerif-lite
 * `<?php echo get_stylesheet_directory(); ?>`
    /homepages/7/xyz/htdocs/AustinWeddingDJs/
   wp-content/themes/zerius
 * `<?php echo get_template_directory_uri(); ?>`
    [http://1weddingdj.com/wp-content/themes/zerif-lite](http://1weddingdj.com/wp-content/themes/zerif-lite)
 * `<?php echo get_stylesheet_directory_uri(); ?>`
    [http://1weddingdj.com/wp-content/themes/zerius](http://1weddingdj.com/wp-content/themes/zerius)
 * if i use :
 *     ```
       <link rel="stylesheet" type="text/css" href="wp-content/menu_files/swimbi.css"/>
       ...
       <script src="wp-content/menu_files/swimbi.js"></script>
       ```
   
 * it all works just fine on every page **except** any testimonial or portfolio 
   pages. However it still works on [http://1weddingdj.com/testimonial](http://1weddingdj.com/testimonial)
   and [http://1weddingdj.com/portfolio](http://1weddingdj.com/portfolio) just not
   the actual portfolio or testimonial pages.
 * see here: [http://1weddingdj.com/testimonial/kindred-oaks](http://1weddingdj.com/testimonial/kindred-oaks)
   
   and see any other pages all working: [http://1weddingdj.com/about-us](http://1weddingdj.com/about-us)
 *  Thread Starter [DanielKYantis](https://wordpress.org/support/users/danielkyantis/)
 * (@danielkyantis)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/get_template_directory_uri/#post-7417112)
 * I’ve tried putting the menu_files directory in various places also.
    so far if
   I put it in the /themes/zerius/ or /themes/zerif-lite/ directory the icons don’t
   work. even if i put it on root the icons don’t work.
 * it seems to only work in /wp-content/
    but then the testimonial pages don’t work
   at all… that is what is odd to me.
 * maybe the issue is the way swimbi.js gets the icons?
 *  [codemovement.pk](https://wordpress.org/support/users/codemovementpk/)
 * (@codemovementpk)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/get_template_directory_uri/#post-7417115)
 * Hello Daniel Yantis,
 * Hope you are in good health. Please add **menu_files/swimbi.css** and **/menu_files/
   swimbi.js** in zerius folder. After that call these files in header like this:
 *     ```
       <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_directory_uri(); ?>/menu_files/swimbi.css"/>
       <script src="<?php echo get_stylesheet_directory_uri(); ?>/menu_files/swimbi.js"></script>
       ```
   
 * Thank you
 *  Thread Starter [DanielKYantis](https://wordpress.org/support/users/danielkyantis/)
 * (@danielkyantis)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/get_template_directory_uri/#post-7417117)
 * Yes i’ve done that. The menu works on all pages but now no icons next to all 
   menu item text.
 * This is why i say maybe issue is in the way the menu call the images?
 *  Thread Starter [DanielKYantis](https://wordpress.org/support/users/danielkyantis/)
 * (@danielkyantis)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/get_template_directory_uri/#post-7417118)
 * I don’t understand the js file exactly. it’s minified and i just don’t get it.
   
   I also don’t know json and its also got base references so that’s over my head
 * There are 3 files to the swimbi menu.
    [http://1weddingdj.com/wp-content/themes/zerius/menu_files/swimbi.css](http://1weddingdj.com/wp-content/themes/zerius/menu_files/swimbi.css)
   [http://1weddingdj.com/wp-content/themes/zerius/menu_files/swimbi.js](http://1weddingdj.com/wp-content/themes/zerius/menu_files/swimbi.js)
   [http://1weddingdj.com/wp-content/themes/zerius/menu_files/swimbiUIcfg.json](http://1weddingdj.com/wp-content/themes/zerius/menu_files/swimbiUIcfg.json)
 * Maybe you could take a look?
 *  [codemovement.pk](https://wordpress.org/support/users/codemovementpk/)
 * (@codemovementpk)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/get_template_directory_uri/#post-7417121)
 * I looked into it but I am afriad that it’s coming from third party solution. 
   Please try to contact [Swimbi.com Swift Menu Builder](http://swimbi.com/contact/)
   and with this ticket.
 * Thank you.
 *  Thread Starter [DanielKYantis](https://wordpress.org/support/users/danielkyantis/)
 * (@danielkyantis)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/get_template_directory_uri/#post-7417122)
 * menus working now.
    making this post closed as the topic is unrelated to the 
   actual issue.
 * [https://wordpress.org/plugins/autoptimize/](https://wordpress.org/plugins/autoptimize/)
   
   I had to exclude swimbi.js in the settings. not sure why exactly, but it was 
   preventing swimbi.js from working right.
 *  [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/get_template_directory_uri/#post-7417124)
 * [@danielkyantis](https://wordpress.org/support/users/danielkyantis/); such problems
   depend on your context and AO settings.
 * if for example you’re not aggregating inline JS and swimbi.js uses JS variables
   that are defined in said inline JS, you can have JS errors. possible solutions
   in that case are to exclude swimbi.js or to include inline JS or to insert the
   autoptimized JS elsewhere (toggling the “load JS in head”-option).
 * hope this clarifies,
    frank (ao dev)
 *  Thread Starter [DanielKYantis](https://wordpress.org/support/users/danielkyantis/)
 * (@danielkyantis)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/get_template_directory_uri/#post-7417126)
 * Thank you for the response. At this time i’m ok with just excluding that 1 file.
   
   It seems there are several ways that the swimbi program can create the files 
   needed for the menu and I used individual files instead of an option to embed…
   or so i’m told.
 * but I don’t want to take the time to recreate it all right now and resave correctly.(
   I messed up the original files and now all i have is the minified output).

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘get_template_directory_uri’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * 12 replies
 * 4 participants
 * Last reply from: [DanielKYantis](https://wordpress.org/support/users/danielkyantis/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/get_template_directory_uri/#post-7417126)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
