• Resolved Alison

    (@anonymical7)


    Hi guys,

    I have found bits and pieces of things online but not anything extensive for the newbie.

    If I have made header files such as:
    headercontact.php
    headerwork.php

    How can I get them to show up on the pages that display that header?

    I found this and modified it online, but each time I try to add it to my functions.php file, I get syntax errors.

    if (is_page(‘contact’)){
(TEMPLATEPATH.’/headercontact.php’);
}
elseif (is_page(‘gallery’)){
(TEMPLATEPATH.’/headerwork.php’);
}
else {
(TEMPLATEPATH.’/header.php’);

    If theres a plugin that could conceivably rotate header.php files that would be cool, but I cant seem to find this and figure I need to learn this.

    Thanks! A

Viewing 6 replies - 1 through 6 (of 6 total)
  • It may be easier to create new page templates and use your code from the files you noted above to replace get_header in new page templates (then assign new templates to pages desired).

    Solution is quite simple.

    Step 1: rename your header files to
    header-contact.php
    header-work.php

    Step 2:
    In your template files, f.e. index.php or page.php or single.php:
    instead of calling get_header(),
    you call
    get_header(‘contact’); or
    get_header(‘work’);

    get_header() will call the header.php file.

    Thread Starter Alison

    (@anonymical7)

    Ah! Thanks! Im going to try it! A
    Really appreciate the fast response!

    If anyone else has feedback, im open to all!

    Thread Starter Alison

    (@anonymical7)

    It worked! But I seem to have lost my editing bar when logged in on those pages.
    You know, the grey one at the top from the wp-admin… but it worked! Thanks!

    make sure you have wp_head() included in the new header-XXX.php files.

    Thread Starter Alison

    (@anonymical7)

    Ah, yes, actually it was the <?php do_action('wp_footer'); ?>
    that was missing. My mistake.

    Thanks all!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Changing header.php files?’ is closed to new replies.