Forums

[resolved] Modified header (7 posts)

  1. ronchicago
    Member
    Posted 3 years ago #

    I made a new template and wish to modify ( simplify )the header for this series of template(s). i modified the code in header.php and made another file header2.php.

    then within the template i called get header2() and got an error message = call to undefined functions. i knew this was too simple and the good news, i guess, i predicted this error message. can anyone point me in right direction or is this way too theme specific?

  2. chaoskaizer
    Member
    Posted 3 years ago #

    FYI get_header function only load "header.php". You can try the below code to load your custom header template.

    <?php // add inside functions.php
    function get_template_header($filename='header'){
    
     $file = TEMPLATEPATH.DIRECTORY_SEPARATOR.$filename.'.php';
    
     if ( file_exists( $file ) ){
         if (has_filter('get_header')) do_action('get_header');
         load_template( $file );
     } else {
         get_header();
     }
    }
    ?>

    usage

    <?php get_template_header('header2'); // get header2.php ?>
  3. ronchicago
    Member
    Posted 3 years ago #

    hello chaoskaizer. thank you.

    i dropped your code into functions.php and then replace my "get header" code with your usage code into my new template. did not work... i think i did it right.

  4. ronchicago
    Member
    Posted 3 years ago #

    i tried replacing this...

    <?php get_header(); ?>

    with this...

    <?php include (TEMPLATEPATH . 'header2.php'); ?>

  5. ronchicago
    Member
    Posted 3 years ago #

    here is the fix!

    chaoskaizer, thank you again. the code above was provided by the theme developer. i just noticed that the " / " was missing...

    <?php include (TEMPLATEPATH . '/header2.php'); ?>

  6. ronchicago
    Member
    Posted 3 years ago #

    new challenge on header2.php...

    i wish to simplify a nav bar that has 10 category titles on it and wish to display only four.

    the existing code =
    wp_list_categories('title_li='); ?>

    i tried this =
    <?php wp_list_categories('title_li=' . 'exclude=4,27,32,33,82,147'); ?> <!-- 10/12/08 -->

    got an error = Parse error: syntax error, unexpected

  7. ronchicago
    Member
    Posted 3 years ago #

    this works!

    <?php wp_list_categories('title_li=&exclude=27,32,33,144,147'); ?> <!-- 11/15/08 -->

Topic Closed

This topic has been closed to new replies.

About this Topic