WordPress.org

Support

Support » How-To and Troubleshooting » Custom Header Per Page

Custom Header Per Page

  • themissile

    @themissile

    Hi!

    I’m trying really hard to figure out how to have a different header on each of three (four?) pages on a website I’m designing for a client.

    http://www.lindsayginn.com/varitalk/
    (I’m using the base theme, Woodtastic)

    I’ve tried some PHP options, some plugins, and furiously bashing my head into the screen of my laptop in hopes for some kind of thought transfer magic, but nothing seems to be working. Can anyone assist?

    [I’ve seen other forum topics with this question, but either the solutions didn’t work for me, or no one had answered, so I started a new topic – apologies of this is a panty buncher!]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Peter_L

    @peter_l

    combine is_post() with the get_header()

    read here: Multi headers
    http://codex.wordpress.org/Function_Reference/get_header

    themissile

    @themissile

    Thanks very much. I figured out the issue.

    It was long and involved, but the only thing that I’ve gotten to work, so…
    For anyone else curious:

    1. Create div#header-about, div#header-projects, etc., in your stylesheet by copying the main div#header code and changing the background image to suit your needs.
    2. Create custom header files (header-about.php, etc.) and replace

    <div id="header">

    with

    <div id="header-about"> or whatever your new div is called.

    3. Create page templates for each of your pages (page-about.php, etc). Replace:

    <?php get_header(); ?>

    with

    <?php include (TEMPLATEPATH . '/header-about.php'); ?>

    Should work! 🙂 Worked for me.

    esmi

    @esmi

    Forum Moderator

    esmi link: “Another CSS based approach” came in handy for custom headers for categories. I did need to add the function below code below since my file did not have it. Here it is.
    ‘<?php

    function page_bodyclass() { // add class to <body> tag
    global $wp_query;
    $page = ”;
    if (is_front_page() ) {
    $page = ‘home’;
    } elseif (is_page()) {
    $page = $wp_query->query_vars[“pagename”];
    }
    if ($page)
    echo ‘class= “‘. $page. ‘”‘;
    }’

    <?php
    
    function page_bodyclass() {  // add class to <body> tag
    	global $wp_query;
    	$page = '';
    	if (is_front_page() ) {
        	   $page = 'home';
    	} elseif (is_page()) {
       	   $page = $wp_query->query_vars["pagename"];
    	}
    	if ($page)
    		echo 'class= "'. $page. '"';
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom Header Per Page’ is closed to new replies.