Results 1 to 5 of 5

Thread: WordPress Headache...

  1. #1
    Join Date
    Jan 2006
    Location
    Ft. Smith, AR
    Posts
    795
    Thanks
    57
    Thanked 129 Times in 116 Posts

    Default WordPress Headache...

    Why is it that this: <?php bloginfo('template_directory'); ?>, will work for things like stylesheets, but I can't make it work for an image?

    <img src="<?php bloginfo('template_directory'); ?>/images/blah.jpg">
    --------------------------------------------------
    Reviews, Interviews, Tutorials, and STUFF
    --------------------------------------------------
    Home of the SexyBookmarks WordPress plugin

  2. #2
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    did you rename your /images/ directory after installing wordpress? the default directory is /img/, not /images/. that may be your problem.
    - Josh

  3. #3
    Join Date
    Jan 2006
    Location
    Ft. Smith, AR
    Posts
    795
    Thanks
    57
    Thanked 129 Times in 116 Posts

    Default

    no, the directory for images inside my theme directory is "images" not "img"
    --------------------------------------------------
    Reviews, Interviews, Tutorials, and STUFF
    --------------------------------------------------
    Home of the SexyBookmarks WordPress plugin

  4. #4
    Join Date
    Jul 2008
    Posts
    138
    Thanks
    13
    Thanked 1 Time in 1 Post

    Default

    I'm not sure how to answer your specific wordpress question but if you can't figure it out, in your template where you are trying to use images you might be able to hardcode it with something like the following...

    PHP Code:
    <?php $TEMPLATE_PATH  $_SERVER[DOCUMENT_ROOT] . '/wp-content/themes/YOUR_THEME/images/'?>
    That can be added to the top of your page so if your path ever changes you only have to change it once in your page. You could also in theory place just that in a page named "wp_temp_path.php" or something similar. If you are working with other pages you could include that path page to use it in the same way across many pages.

    Where you want to place an image, you should be able to do something like this...

    PHP Code:
    <img src="<?php echo "{$TEMPLATE_PATH}blah.jpg"?>">
    That way if you know your image is in the images folder, you can just add it like above and php should do the rest for you.

    I can understand that wordpress is what you are working with so you would like to figure it out, but if no one else has any suggestions the above might work for what you are trying to do. Hope that helps.

  5. #5
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default

    After you do that, view the source and look at the output. Does it link to the correct image path?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •