Menu icon Foundation
wp functions in interchange?

Im using JointsWP to make a wordpress blog, I'm also using foundation 5 ofcourse. I have a file called "headerMedium.php" that loads via interchange.js. The file loads as it should, but inside of "headerMedium.php" the following wordpress function seem to produce a php error since the img tag won't even show in the source code:

<img src="<?php echo get_template_directory_uri(); ?>/img/picture1.jpg" alt="little oranges" />
            

         

Anybody knows why?

interchangejointswpPHPwordpress

Im using JointsWP to make a wordpress blog, I'm also using foundation 5 ofcourse. I have a file called "headerMedium.php" that loads via interchange.js. The file loads as it should, but inside of "headerMedium.php" the following wordpress function seem to produce a php error since the img tag won't even show in the source code:

<img src="<?php echo get_template_directory_uri(); ?>/img/picture1.jpg" alt="little oranges" />
            

         

Anybody knows why?

Esa Rantanen about 5 years ago

Hello Robin,

first, try giving absolute path to image. Next, change the file extension to .html and see if it works. Next check if php can be run on .html files on your server and debug further.

Robin Cox about 5 years ago

Hi Esa, it's only wordpress functions that won't work. It works if I echo out the full path with php.

Robin Cox about 5 years ago

After some research I think I have the answer.

Seems that because my file "headerMedium.php" is loaded via javaScript, it has no connection to Wordpress thus don't know what "get_template_directory_uri()" is.

Lance Butler about 5 years ago

You could always try requiring wp-blog-header.php in your partial: headerMedium.php.

<?php
/* Short and sweet */
require( './wp-blog-header.php' );
?>