skip to Main Content

I am trying to figure out why my image won’t add to the WordPress website I am creating. This course came with other images that will display but not the ones I add as a jpg file. I am not sure why it will add the other jpg images but not the ones I want. Here’s my code:

<?php get_header(); ?>
<div class="page-banner">
      <div class="page-banner__bg-image" style="background-image: url(<?php echo 
      get_theme_file_uri('images/traffic.jpg') ?>)"></div>
      <div class="page-banner__content container t-center c-white">
        <h1 class="headline headline--large">TBS</h1>
        <h2 class="headline headline--medium">Working to make traffic safer</h2>
        <h3 class="headline headline--small">Explore constructing, utlities, and other types of work we do</h3>
        <a href="#" class="btn btn--large btn--blue">Service & Support</a>
        <a href="#" class="btn btn--large btn--blue">Signs</a>
        <a href="#" class="btn btn--large btn--blue">Utilities</a>
      </div>
    </div>

I am not sure if I need to add more information to this.

2

Answers


  1. Chosen as BEST ANSWER

    I figured it out. I added the image to my image folder but it wasn't refreshed in VS editor. If you add images to a folder, make sure to refresh the image folder.


  2. Try this:

    <div class="page-banner">
        <div class="page-banner__bg-image" style="background-image: url(<?php echo
    get_theme_file_uri('images/traffic.jpg'); height:200px;width:100% ?>)"></div>
          <div class="page-banner__content container t-center c-white">
            <h1 class="headline headline--large">TBS</h1>
            <h2 class="headline headline--medium">Working to make traffic safer</h2>
            <h3 class="headline headline--small">Explore constructing, utlities, and other types of work we do</h3>
            <a href="#" class="btn btn--large btn--blue">Service & Support</a>
            <a href="#" class="btn btn--large btn--blue">Signs</a>
            <a href="#" class="btn btn--large btn--blue">Utilities</a>
          </div>
        </div>
    

    Problem is that you are closing <div> tag without adding any content in that:

    <div class="page-banner__bg-image" style="background-image: url(<?php echo
    get_theme_file_uri('images/traffic.jpg') ?>);"></div>
    

    So I have added height and width for showing the background image. Either you can add some content or specify the height and width of that div.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search