In WordPress, I've been installing and using various themes, including 2013, Roots, and now BlankSlate. I noticed that now that I've activated BlankSlate, the function
get_template_directory() used in front-page.php is still returning the path to the Roots theme directory. My current front-page.php looks like this.
<?php get_header(); ?> <section id="content" role="main"> <img class="frontpageimg" src="<?php get_template_directory(); ?>/images/slogan-2.png"> <h4>In the Los Angeles area? </h4> <p>Ask about free demo loaners! </p> <h4>We also take mail orders.</h4> On all orders, there is a 30-day return policy!</p> <img src = "<?php get_template_directory(); ?>/assets/img/cables-ers-absorber-700.jpg"/></a> <img src = "<?php get_template_directory(); ?>/assets/img/blueprint-silencers-v2-700.jpg"/></a> <img src = "<?php get_template_directory(); ?>/assets/img/brav-front-page-700.jpg"/></a> <a href="contact" class="btn btn-lg btn-orange">Contact Us</a> </section> <?php get_sidebar(); ?> <?php get_footer(); ?>
EDIT UPDATE: Did some some debugging as follows:
Deactivated all plugins. Logged out, cleared cache. The problem persisted.
Switched from BlankSlate (in which the problem was evident) to 2013 theme. Similar behavior, although I now can say more specifically what that behavior is. While in the 2013 theme, apparently the PHP construct
<?php echo get_template_directory(); ?>/path-in-2013-theme/file.jpg works, but
<?php get_template_directory(); ?> returns the path to the Roots theme. The same is true of
<?php echo get_template_directory_uri(); ?> (works correctly with the
echo but not without).
However, the behavior is somewhat different in BlankSlate. Without the
get_template_directory_uri() return the path to Roots theme, while with the
echo they do something else (but I'm not sure what that something else is.. how do I dump these values for debugging?)
I was able to inspect the page source with Firebug. Sure enough, the functions had no output without echo. So the image source was
src="/assets/img/brav-banner-3.jpg and so forth. And that worked in some themes. I mean I could see the image. So maybe it's a caching problem? When I added the echo and changed the path to the jpg, I was able to get it to work in the BlankSlate theme. So I am going to mark this solved, as a caching issue.