[resolved] Image not showing (5 posts)

  1. Lanzagirl
    Posted 8 years ago #

    I made some changes to the sidebar.php in the theme I am using (retro-book-10). I can't understand why the image doesn't show? Can anyone help me please?

    <div id="SIDE">

    <h2>English </h2><p>


      <?php wp_list_pages('title_li=' ); ?>
      <?php wp_list_categories('show_count=1&title_li='); ?>

    <?php include (TEMPLATEPATH . '/searchform.php'); ?>

    <h2><img src="/images/crest.jpg"><h2>


  2. Kafkaesqui

    Posted 8 years ago #



    points to a directory called 'images' at the root of your site. So assuming a domain name of example.com, 'images' would be accessible as:


    is this the case for your images directory? I suspect rather the path to it is:


    so your best option in your template is to use WordPress' 'template_directory' value for bloginfo() to output the path to your active theme's directory, like so:

    <img src="<?php bloginfo('template_directory'); ?>/images/crest.jpg">

    EDIT: Missed my morning coffee. Removed reference to TEMPLATEPATH constant (which is bad for this) and stuck in the bloginfo() stuff.

  3. westpointer
    Posted 8 years ago #

    Could you explain more the difference between using TEMPLATEPATH and bloginfo('template_directory')? Why pick one over the other?

  4. Kafkaesqui

    Posted 8 years ago #

    TEMPLATEPATH = actual (absolute) directory path on the host server. Useful for passing the path to the PHP include() function and whatnot (you can see its use in Lanzagirl's code above).

    bloginfo('template_directory') = full url to the directory, which is what you want to provide in the case of say the src for an img element.

  5. Lanzagirl
    Posted 8 years ago #

    Thanks. That worked for me. I had tried it with http://www..... etc. including that as you wrote it, before but it didn't. Strange!

Topic Closed

This topic has been closed to new replies.

About this Topic