WordPress.org

Forums

[resolved] Adding images to a theme (3 posts)

  1. Susan
    Member
    Posted 6 years ago #

    Hi,

    I have recently created a new theme called "mytheme".

    On the sidebar I wish to include an image. I have placed the image in a directory called "images" inside the "mytheme" directoy.

    In sidebar.php I have the <img> src set to "wp-content/themes/mytheme/images/nice_picture.png"

    This image displays fine in the sidebar on the homepage. The problem is on a page with an individual post, the path to the image is no longer correct as we are two directorys deeper.

    How do I make the path to the image more general to work on all pages?

    Thank you,
    Shoesie.

  2. noonoo
    Member
    Posted 6 years ago #

    Hi, i had the same problem a while back you want to use the code below:

    <img src="<?php bloginfo('template_directory'); ?>/images/nice_picture.png" border="none" alt="alternative text" />

    Hope this helps

  3. Susan
    Member
    Posted 6 years ago #

    Thanks so much. That worked perfectly.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags