How display img in index.php

I have themplate it works fine no problem.

when I try to convert the themplate to theme wordpress, I copy all the content to
index.php theme inside the the content I got the below code:

Read More
<ul>
                                <li>
                                    <div class="box-1">
                                        <img src="images/page1-img1.jpg" alt="" /> <a href="#">bora-bora</a>
 <span>from $458</span> 
                                        <p>Praesent vestibulum aenean
                                            <br>nonummy hendrerit mauris.</p>
                                    </div>
                                </li>
                                <li>
                                    <div class="box-1">
                                        <img src="images/page1-img2.jpg" alt="" /> <a href="#">Hawaii</a>
 <span>from $458</span> 
                                        <p>Praesent vestibulum aenean
                                            <br>nonummy hendrerit mauris.</p>
                                    </div>
                                </li>

the images are not display on the screen.

I can see my theme in url:`http://127.0.0.1/www/www1/wordpress/Heb/wordpress/

to see the img I can see with full path:

http://127.0.0.1/www/www1/wordpress/Heb/wordpress/wp-content/themes/yossi_theme/images/page1-img1.jpg

if I click right mouse on the picture wich I can’t see, and copy target url,I got the adress:

http://127.0.0.1/www/www1/wordpress/Heb/wordpress/images/slide-1.jpg

and the error :The requested URL /www/www1/wordpress/Heb/wordpress/images/slide-1.jpg was not found on this server.

what should I change here <img src="images/page1-img1.jpg" alt="" /> to display the img ?

many thanks.

Related posts

Leave a Reply

2 comments

  1. Since you said that the full path of your image is

    http://127.0.0.1/www/www1/wordpress/Heb/wordpress/wp-content/themes/yossi_theme/images/page1-img1.jpg
    

    then you can try this

    <img src="<?php echo get_template_directory_uri()?>/images/yourImageName.png" alt="" />
    

    instead of

    <img src="images/yourImageName.png" alt="" />
    

    get_template_directory_uri() will return your theme folder’s path, i.e.

    http://127.0.0.1/www/www1/wordpress/Heb/wordpress/wp-content/themes/yossi_theme
    
  2. If this image is a part of your layout (not part of the content), you can either use entire path (eg. http://localhost/image.jpg) or place it in your theme’s directory (let’s say, [your theme]/images and then use <img src="<?php bloginfo('template_directory'); ?>/images/image.jpg" alt="">.

    If this is a part of your content (post, page, whatever), upload this file through WordPress admin and place it from there.