wordpress: how to add a custom static HTML page template with some images in it

i have created a custom static html page
by adding a php file in

 wp-content/themes/myactivetheme/

containing essentially

Read More
<?php
  /*
  Template Name: test
  */
  ?>
  <div><p>blablabla</p>
 <div><img src="content/images/thumb/00500_Partition_Vivaldi_Printemps.jpg"  /></div>

i have placed the corresponding image file in

wp-content/themes/myactivetheme/content/images/thumb

When creating a new page with the dashboard using this test template , the text is displayed but not the image, why?

Related posts

Leave a Reply

3 comments

  1. Probably the source address for the image is wrong. Don’t use relative links. For example:

    Instead of:

    <img src="content/images/thumb/00500_Partition_Vivaldi_Printemps.jpg"  />
    

    Use:

    <img src="<?php bloginfo('template_url'); ?>/content/images/thumb/your-image.jpg" />
    

    It will help WordPress to find the exact path to display your image.

  2. Relative URIs will be relative to your WordPress index, so WordPress will look for the image in the wrong place. You could

    1. move the image
    2. hard code the image url
    3. do it the clean and right way, which is <img src="<?php echo get_stylesheet_directory_uri(); ?>/content/images/thumb/00500_Partition_Vivaldi_Printemps.jpg" />