Different headers coding. (4 posts)

  1. techbunny
    Posted 3 years ago #

    Hi guy's,

    I've been trying to develop a wordpress template to use different header images on each page. I have found several closed topics which have been helpful but I'm at a sticking point where I think the code is correct but the images are not displaying.

    The topic I have used for reference is: http://wordpress.org/support/topic/different-headers-for-each-page

    The coding I have placed into my Main Index Template.php is:

    get_header(); ?>
    <?php if (is_home()) get_header(); ?>
    <?php if (is_page(wh-casino()) include(get_template_directory() . 'http://techbunny.net/wp-content/uploads/2012/12/Sturgeons-078.jpeg'); ?>

    I'm wondering if using the page name (wh-casino) or the image url is what's causing the code to fail, please can someone point me in the right direction?

    Thanks :)

  2. Andrew Nevins
    Forum moderator
    Posted 3 years ago #

    This is generating an invalid URL

    include(get_template_directory() . '<em>http://techbunny.net/wp-content/uploads/2012/12/Sturgeons-078.jpeg</em>');

    It's outputting something like this


    Perhaps you just want either this;

    include(get_template_directory() . 'uploads/2012/12/Sturgeons-078.jpeg');



    You shouldn't have HTML elements in include functions.

  3. techbunny
    Posted 3 years ago #

    Hi Andrew,

    I was literally just editing my post because the italics tags were to highlight the two areas I think were causing problems but they are not present in my code.

    I will try your suggestions, thank you for a fast response :)


    Edit: Both of Andrew's options are not changing the header for me. The page I wish to change a header image on is renamed to: wh-casino so I have updated my coding to display the page name as wh-casino instead of 8 as my initial post states.

    In my Main Index Template (index.php) I have placed the codes in as follows:

     * @package WordPress
     * @subpackage Default_Theme
    <?php if (is_home()) get_header(); ?>
    <?php if (is_page(wh-casino()) include(get_template_directory() . 'uploads/2012/12/Sturgeons-078.jpeg'); ?>
    get_header(); ?>

    Can anyone else advise?

  4. Andrew Nevins
    Forum moderator
    Posted 3 years ago #

    What happens if you add a forward slash before uploads?


Topic Closed

This topic has been closed to new replies.

About this Topic