• An attempt to try to use WP-display-header and custom-header-extended fail. Says the theme is not supported for the plugins.

    Is there anything I need to change?

Viewing 1 replies (of 1 total)
  • Hi,

    I think you want to use HEADER IMAGE for different pages.Actually there are many ways to do this in PHP.I am gonna share that came into my mind first.I don’t know exactly how you want to do it, so I am providing you an idea about what you want to do.

    1-
    If you want to display RANDOM HEADER IMAGE on different pages like whenever the page is refreshed, the header image will be changed RANDOMLY.

    Overview:
    You need to upload some header images in the themes IMAGES folder.
    eg: you want 5 different header images.Each image should have been saved with this PATTERN names: image1.jpg,image2.jpg,image3.jpg,image4.jpg,image5.jpg,
    – We will use a PHP Random number between 1 & 5 to display RANDOM HEADER image on different pages.

    For this, I have written some code, just take a look at it.
    You need to paste this in your theme Header.php file.

    <div class="custom-header"><!-- Just a CUSTOM DIV NAME -->
    <?php $id = get_the_ID();//get current page id ?>
    <img id="custom-header" src="PATH TO YOUR THEME DIRECTORY/hiero/IMAGES FOLDER NAME/image<?php echo htmlspecialchars(rand(1,5));?>.jpg" alt="cutom_header_<?php echo get_the_title($id); ?> "/><!-- DISPLAY IMAGE using ID-->
    </div>

    The id=”custom-header” is used to STYLE the IMAGE with CSS.I hope you can style the images as you want.

    RECOMMENDED: Please use Custom PLUGIN(I LIKE MY CUSTOM CSS) while adding custom CSS to themes.

    2-
    If you want to display single different HEADER IMAGE for every different page you can do it like this.
    – GET the PAGE IDs from the WP backend. eg(Home = 1, About = 2, Contact = 3)
    You can use this kind of code to do the job:

    <?php
    if ( is_front_page() ) {
       //display homepage header image
    ?>
       <img id="custom-header" src="PATH TO YOUR THEME DIRECTORY/HOMEPAGE_IMAGE.jpg" alt="cutom_header"/>
    <?php
    } elseif ( is_page( 'About' ) ) {
        //display About Us header image
    ?>
       <img id="custom-header" src="PATH TO YOUR THEME DIRECTORY/ABOUT_IMAGE.jpg" alt="cutom_header"/>
    } elseif ( is_page( 'Contact' ) ) {
         <img id="custom-header" src="PATH TO YOUR THEME DIRECTORY/CONTACT_IMAGE.jpg" alt="cutom_header"/>
    }

    RECOMMENDED:
    Please create your CHILD theme first to do CUSTOM EDITING, if you don’t want to lose your coding when THEME is updated.

    I hope this gives you a close idea.
    Please let me know if you have something to ask.Thanks

Viewing 1 replies (of 1 total)
  • The topic ‘Header Image’ is closed to new replies.