PHP path query returns /app/public/ instead of http://mysite.local/

Hi everyone,

while creating a theme, I use <?php echo get_template_directory(); ?> and things related to the path on a regular base. Obviously. But while testing with local by Flywheel, this results in:

/app/public/wp-content/themes/mytheme…

instead of:

http://mysite.local/wp-content/themes/mytheme…

It is possible that this is a mistake at my end. It’s more than possible, it’s probably so. But anyway: all help welcome.

Have a nice evening,

Kind regards.

Hi @24degrees,

get_template_directory() returns the path of the path to the file on the web server. If you are wanting the URL instead of the path, try get_template_directory_uri().

Also, another quick tip: if you’re using a child theme, you will need to use get_stylesheet_directory_uri() since get_template_directory_uri() will return the URL to the parent theme.

Hi Clay,

thank you so much for your answer. This helped me a lot. I got a lot of issues solved now. I thought it was a local by flywheel setting but it turned out to be my mistake.

Still one issue standing:

source type=“video/mp4” src="<?php echo wp_get_attachment_url(7); ?>"

The above code works for item 7, because it is hard coded. But how do I replace the 7 with the value from a customizer setting called introsectionvideo?

Would be cool if you happen to know that. meanwhile my quest continues :wink:

Have a nice evening and thanks !

Think I found it Clay, just sharing it for others:

source type=“video/mp4” src="<?php echo wp_get_attachment_url(get_theme_mod( 'introsectionvideo')); ?>"

Thanks again !

1 Like

@24degrees,

Glad I could help! Thanks for sharing your solution as well :slight_smile:

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.