WordPress.org

Ready to get started?Download WordPress

Forums

static image header on some pages (5 posts)

  1. DuendeB25
    Member
    Posted 6 months ago #

    Hello I wanted to ask you a question about the images in the headers. I put in a situation I have several images in the header which change randomly. In some pages I wanted them to be fixed and will not change. Can you do what I have in mind? Can you give me any recommendation as to if you could? Greetings and thanks.

  2. bcworkz
    Member
    Posted 6 months ago #

    Sure you can!

    Exactly how would depend on how your header images are currently retrieved. For example, you could use a select/case structure where each case is a post ID that outputs a specific image path. The default case would then output the random image the same way as is done currently.

  3. DuendeB25
    Member
    Posted 6 months ago #

    Where would have to put the path of the image in the header file or function? You can give me an example to do me an idea of ​​how to do it. Thanks for your time.

  4. bcworkz
    Member
    Posted 5 months ago #

    Where ever you want the image to appear in header.php might look something like this (I had the wrong language in my mind when I said select/case, it's switch/case):

    <img src="<?php
       if (is_singular()){
          switch $post->ID {
          case 22:
             echo "http://example.com/wp-content/uploads/2014/3/image22.jpg;
             break;
          case 69:
             echo "http://example.com/wp-content/uploads/2014/3/image69.jpg;
             break;
           default:
              header_image();
          }
       } else {
          header_image();
       }
    ?>"/>
  5. DuendeB25
    Member
    Posted 5 months ago #

    thanks for replying I will study the code and try to implement on my website. regards

Reply

You must log in to post.

About this Topic