Grow your CSS skills. Land your dream job.

WordPress wont show images

  • # October 26, 2008 at 5:19 pm

    I have to put some images inside the header.php file and none of them are showing up. really confused as to why this is happening. theyre in the images folder and the css images are showing up with the same file path but not the in document images.
    im using the starkers template base.

    any ideas?

    # October 26, 2008 at 5:40 pm

    I ran into the same thing. In my stylesheet, I can use url(‘images/logo.gif’) and it displays just fine. However, on any of the pages, if I use <img src="images/logo.gif" /> it won’t display.

    The reason is that, in the latter case, WP is looking for the image in it’s main directory. If you specify the entire path it will work:

    <img src="/wp-content/themes/your_theme/images/logo.gif" />

    Alternately, you could define a variable with the path.

    Put <?php define(‘IMGPATH’, ‘/wp-content/themes/your_theme/images/’); ?> in your header file and then reference images like this:

    <img src="<?php echo IMGPATH; ?>logo.gif" />

    There is probably a better way but I’m new to WP as well and this is the best I’ve found so far.

    # October 26, 2008 at 6:06 pm

    ahhhh thats bizarre to me.
    i dont really understand why, if these files including my css live in the theme directory, why it would look outside of that for images. unless it has something to do with the wordpress upload mechanism but that doesnt really make sense either since im physically putting these here.

    it did work though.

    i think i had this problem before on another blog but i ended up using CSS ultimately. for this i need them in the document.

    thanks for the help!!! saved me at minimum an hour of screwing around probably.

    # October 27, 2008 at 12:50 am

    *Update:

    After the full path fixed the issue when i was on the index page, once i set up subpages and started trying to navigate to them, those same images we’rent showing up by my css backgrounds were. all these images are in the header file. i added "../" before those file paths and theyre now working in sub pages which is also very strange to me, so far it doesnt appear to break the index page so looks like this might be the fix for it. we’ll see.

    # October 27, 2008 at 2:10 am

    I like using this method

    <img src="<?php bloginfo(‘template_directory’) ?> images/imagename.jpg" alt="" />

    # October 27, 2008 at 2:45 pm

    I like that much better. It’s cleaner. I’m still pretty new to WP so I didn’t know about bloginfo(‘template_directory’) yet. Thanks!

    # October 27, 2008 at 6:48 pm

    you should check the wordpress website. There are a bunch of tags that you can use in wordpress to do a whole bunch of things. Like get the most popular article, most recent, last 10 and so on. I think they call them template tags.

    http://codex.wordpress.org/Template_Tags

    # October 27, 2008 at 8:25 pm

    Woot! Goldmine!

    That’s exactly what I needed. I’ve been meaning to look at their site for a while but hadn’t gotten to it yet. Glad to see they have good info there.

    Thanks!

    # November 28, 2008 at 11:06 am

    EDITED
    I was wrong. It didn’t work for me. I tried 3 of the methods above and it didn’t work. What could be the problem?
    The problem is, when I use

    Code:
    url(images/comment_bubble.gif)

    it shows but when I try to use

    Code:

    it just won’t work. ANy idea?

    # March 31, 2013 at 3:17 pm

    Hi guys!

    I got stucked! I´m using a child theme and the:

    # March 31, 2013 at 3:18 pm

    The following code: < ?php bloginfo('template_directory'); ?> _images/demos/demo03.jpg” /> It just did´t work until i puted images in the parent directory. Any thoughts?

    # March 31, 2013 at 3:22 pm

    @ray_acosta

    Please start a new thread instead of bumping a 5 year old one.

Viewing 12 posts - 1 through 12 (of 12 total)

The topic ‘WordPress wont show images’ is closed to new replies.

*May or may not contain any actual "CSS" or "Tricks".