WordPress.org

Ready to get started?Download WordPress

Forums

image urls (4 posts)

  1. verymum
    Member
    Posted 7 years ago #

    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="http://mydomain.com/wp-content/themes/themename/images/icon.gif" 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?

    Thanks.

  2. alakhnor
    Member
    Posted 7 years ago #

    <img src="<?php bloginfo('stylesheet_directory'); ?>/images/icon.gif" alt="comment icon" />

  3. verymum
    Member
    Posted 7 years ago #

    Thank you!!

  4. verymum
    Member
    Posted 7 years ago #

    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: http://verydad.com/2007/03/19/hello-world/

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags