Support » Themes and Templates » image urls

  • I am developing my first wordpress theme. I have developed many for myself, and always used the full image url if placing an image in the index.php or header.php files (ie: the header/logo image or small icons next to “comments” and “permalink”) like so:

    <img src="" alt="comment icon" />

    Now that I’m trying to make a theme for everyone to use, I have removed the full url to this:

    <img src="wp-content/themes/themename/images/icon.gif" alt="comment icon" />

    Which of course breaks the image if I navigate to another page or category page that inserts a new directory into the url.

    I know I can fiddle with calling images in the CSS, but I didn’t want the header image to be a background, I want it clickable. Is there some kind of php string that will work inside the image tag to call the images from the right directory?


Viewing 3 replies - 1 through 3 (of 3 total)
  • <img src="<?php bloginfo('stylesheet_directory'); ?>/images/icon.gif" alt="comment icon" />

    Thank you!!

    I’m having a bit more trouble. I’m wanting to put a comment icon inside the feedback string:

    <?php wp_link_pages(); ?>
    <?php comments_popup_link(__('<img src="<?php bloginfo('stylesheet_directory'); ?>/images/comment.gif" alt="comment" style="border: 0; vertical-align: middle;" />  Would you like to be the first to leave a comment?'), __('1 Comment'), __('% Comments')); ?>

    This causes a parse error – I know I can place it outside the php but I have an if and statement that hides the comment # on the post pages, and if I leave the icon outside, the icon shows up but the comment line doesn’t.

    You can see it when I put the image outside here:

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘image urls’ is closed to new replies.