Forums

Conditional Header (based on posts category or page template) - How? (3 posts)

  1. truncale
    Member
    Posted 1 year ago #

    I would like to have a different header for each category. I was able to create conditional sidebars with each category (using include)...

    <?php
    $post = $wp_query->post;
    if (in_category('3')) { 
    
     include(TEMPLATEPATH . '/sidebar3.php');
    
    } elseif (in_category('4')) {
    
    include(TEMPLATEPATH . '/sidebar4.php');
    
    } else {
    
    include(TEMPLATEPATH . '/sidebar_post.php');
     }
     ?>

    now I would like to do it with the header, but I'm not sure how to do it with the get_header function. Can someone help? I don't want to mess things up. Can I just use include?

    I also want to use different headers with different pages.

  2. moshu
    Member
    Posted 1 year ago #

    The same way as you did with the sidebar and for the last 'else' you call the generic header
    else {
    get_header();

    I assume you are doing all the above code and stuff in a category.php template file.

  3. Dgold
    Member
    Posted 1 year ago #

    Or, alternatively, you could do it inside header.php

    with IF IN CATEGORY 3... DO THIS STUFF...

Topic Closed

This topic has been closed to new replies.

About this Topic