• Resolved URE

    (@ure)


    Hi Guys!

    Please help me if you can! I have a code that works perfectly in inbox.php, but the same code in single.php doesn’t show the images! Why is that?
    In the code I use shorten urls
    Here is an example of the code:

    <li class=”istylei0 “><span><img src=”wp-content/themes/VA/images/Musej.png”/>Sākums</span><![if gt IE 6]><![endif]><!–[if lte IE 6]><table><tr><td><![endif]–>
    <!–[if lte IE 6]></td></tr></table><![endif]–>

    So this code shows the png file in the inbox.php, but in the single.php doesn’t (png is shown in the post page, but when I select a single post the png file isn’t shown)!

    But when I use a full url – the png is visible! Why is that? How can I fix it?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator James Huff

    (@macmanx)

    That’s because you’re using the relative link wp-content/themes/VA/images/Musej.png which says this-page/wp-content/themes/VA/images/Musej.png .

    So, on the main page, you would have domain.com/wp-content/themes/VA/images/Musej.png which works perfectly, because it exists. But, on a post you would wind up with domain.com/post/wp-content/themes/VA/images/Musej.png which doesn’t exist.

    The solution would be to use either the absolute link:

    https://www.domain.com/wp-content/themes/VA/images/Musej.png

    Or, use PHP to call the stylesheet’s location. This is the preferred method.

    Try this:

    <li class="istylei0 "><span><img src="<?php bloginfo('stylesheet_directory'); ?>/images/Musej.png"/>Sākums</span><![if gt IE 6]><![endif]><!--[if lte IE 6]><table><tr><td><![endif]-->
    <!--[if lte IE 6]></td></tr></table><![endif]-->
    Thread Starter URE

    (@ure)

    Worked like a charm! ?? Thx!

    Moderator James Huff

    (@macmanx)

    You’re welcome!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘code in inbox.php works like a charm, but the same code fails in single.php’ is closed to new replies.