WordPress coding issue...

Discussion in 'CSS' started by FanAddict, Mar 26, 2007.

  1. #1
    Here is the problem im having...

    When I upload a theme to my site: http://www.onlyblogthemes.com/testrun/
    the images in the SIDEBAR show up perfectly fine.

    Then when I upload to themes.wordpress.net - they don't :(


    Here is a piece of code from the sidebar...

    <img src="<?php bloginfo('url'); ?>/wp-content/themes/RedGold/img/sponsors.gif" width="179" height="15" alt="Categories" />


    Is that correct path? It works fine on my sites.. then not on the themes.wordpress.net viewer :(
     
    FanAddict, Mar 26, 2007 IP
  2. crazybjörn

    crazybjörn Peon

    Messages:
    270
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If I remember correctly then you should use relative paths, ie.:

    <img src="/images/headerimgs/header1.jpg" alt="header" />

    wordpress should be able to figure out that you mean the images folder that's inside the theme folder.
     
    crazybjörn, Mar 27, 2007 IP
  3. TomK32

    TomK32 Peon

    Messages:
    113
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Totally wrong. You cannot assume that there's always a wp-content directory and the theme directory is always the same. theme.wordpress.net does downcase for the directory name.
    the working thing should be:

    <img src="<?php bloginfo('stylesheet_directory'); ?>/img/sponsors.gif" width="179" height="15" alt="Categories" />
     
    TomK32, Mar 29, 2007 IP
  4. FanAddict

    FanAddict Notable Member

    Messages:
    7,017
    Likes Received:
    376
    Best Answers:
    0
    Trophy Points:
    230
    #4

    Thanks I will give that a go :)

    Those images are not in the style sheet though... should still work?
     
    FanAddict, Mar 29, 2007 IP
  5. TomK32

    TomK32 Peon

    Messages:
    113
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    OK, again for the slow:
    bloginfo('stylesheet_directory'); this output the directory of the currently used theme. The blog-user might change the themes directory or wp-content directory or even the directory name of the theme so that's the only save way to do this.
    The images don't have to be listed somehow in the stylesheet-file.
     
    TomK32, Mar 29, 2007 IP