WordPress.org

Ready to get started?Download WordPress

Forums

Header Includes (9 posts)

  1. rob0210
    Member
    Posted 6 years ago #

    Hi all,

    I have a little issue i'm hoping to get resolved.

    Its all about header includes.

    With my set up I have a header which is to include different header images dependent on which page of the site your on. I only wanted to call this once hence why I placed it in the header.

    I have in my header.php for eg:

    if $thispage = ('Home'); { include ('headerimage1.php');
    }
    elseif $thispage = ('Blog'); { include ('headerimage2.php');
    }

    Then above my header call on each template page if have:

    $thispage = 'Home';

    Unfortunately they do not seem to be called through... the code is right as I have used it on a none WP website.

    Now I have tried the includes in each template page and they do work but It isn't really ideal as I would rather only change 1 page than 20!

    has anyone else had any issues with this? or any suggestions... I can supply more info if needed.

  2. rob0210
    Member
    Posted 6 years ago #

    This is driving me mad... wordpress does allow php code to come before the header is called right?

    I really cant see what the issue is!... Any help would be really great

  3. rob0210
    Member
    Posted 6 years ago #

    Ok done a bit of testing, pretty much figured out that no matter what I call on the page before the header is included this is ignored other than the template call..is this correct?

  4. rob0210
    Member
    Posted 6 years ago #

    Last chance at getting an answer to this.... I realise the forums are crammed with 2.5 disasters but any help with this would be great.

  5. Clicknathan
    Member
    Posted 6 years ago #

    Hi Rob,

    Not that it's going to be much "help", but I can confirm that you can't add that type of information before the header call. I've tried it every which way over and over again, it seems that WordPress kills those variables you're writing.

    An idea that I had was to call whatever variable is used to determine a Page Template, however I never got any takers on my support request.

    I'm not the master of PHP, though, but perhaps you might have the ability to look into this.

  6. rob0210
    Member
    Posted 6 years ago #

    Thanks clicknathan, it did occur to me that it must be WP doing something as my code all seems fine!

    The only thing I can think to do now is use the is_template tag and call the style and images that way, still don't know whether it will work though and think this conditional tag is only available in 2.5? May be wrong

  7. Clicknathan
    Member
    Posted 6 years ago #

    Did you have any luck with is_template, Rob?

  8. rob0210
    Member
    Posted 6 years ago #

    To be honest I scratched the idea and made seperate images on each template page :( My reasons are as follows:

    1) The website I need it for is currently on 2.3.3 and I am not really prepared to upgrade yet until 2.5 has more of its bugs ironed out.

    2) I have never really experimented with is_page_template and I dont want to upgrade to 2.5 just to test to see it works.

    3) I have a deadline of Thursday for this project so experimental time is nill!

    I will keep this thread open and If I figure anything out I will post it up.

    Meanwhile, anyone who knows what is_page_template is capable of and if it can be used in wp header or not, would be much appreciated if some light could be shed! Thanks

  9. dave_t
    Member
    Posted 6 years ago #

    hey guys, check the thread you have going here, mfields has posted a (possible) solution... I'm doing something similar with is_page_template. if you do wanna use is_page_template(), make sure you pass it the template filename, not the name you assign it within that file. eg use is_page_template('page-about.php') not is_page_template('about'). The is_page_template() function lives in 'wp-includes/post-template.php' in your WP2.5 install. If you wanna test how this works, put the following in your sidebar: `<php
    /* test page template */
    if (is_page_template('page-home.php')) {
    echo ('<h2>Home template</h2>');
    } else {
    $custom_fields = get_post_custom_values('_wp_page_template',$post->ID);
    $page_template = $custom_fields[0];
    echo ('<h2>' .$page_template. '</h2>');
    }
    ?>` (i grabbed the second half of this directly from the post-template.php include, so if you're running WP2.3, maybe see if you can manually retrieve the current page template using the '_wp_page_template' call as above? )

Topic Closed

This topic has been closed to new replies.

About this Topic