Forums

(Newbie) TEMPLATEPATH outputs computer's file path instead of URL path (4 posts)

  1. britsky
    Member
    Posted 4 years ago #

    I'm an experienced programmer using WordPress for the first time :) I'm customizing a theme, and ran into this situation...

    <img src="images/Hello.jpg" >

    The Hello.jpg file is located under the theme's folder:
    /wp-content/themes/Hello_World_Theme/images/Hello.jpg

    When I view the page, the image doesn't show up, because it's looking for it in /images
    instead of /wp-content/themes/Hello_World_Theme/images

    After doing some research, I found out about TEMPLATEPATH and tried using it like this in the index.php file:

    <img src="<? echo TEMPLATEPATH ?>/images/Hello.jpg" alt="Header" />

    I expected the output to look like this:
    <img src="wp-content/themes/Hello_World_Theme/images/Hello.jpg" alt="Header" />

    Instead, I got the computer's file path:
    <img src="D:\Program Files\xampp\htdocs/wp-content/themes/Hello_World_Theme/images/Hello.jpg" alt="Header" />

    Even though I'm viewing it online (not off my local box).

    Obviously, the image did not show up. So, what should I use instead of TEMPLATEPATH??

    Thanks, and God bless!
    -Jeff

  2. actorjiml
    Member
    Posted 4 years ago #

    Jeff,

    This should get you on the right PATH. ;-)

  3. britsky
    Member
    Posted 4 years ago #

    Alright!
    <?php bloginfo('template_directory'); ?> did the trick.

    Many thanks!
    -Jeff

  4. Chris_K
    Member
    Posted 4 years ago #

    *groan* very punny. ;-)

Topic Closed

This topic has been closed to new replies.

About this Topic