WordPress.org

Ready to get started?Download WordPress

Forums

Custom Header Per Page (6 posts)

  1. themissile
    Member
    Posted 3 years ago #

    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!]

  2. Peter_L
    Member
    Posted 3 years ago #

    combine is_post() with the get_header()

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

  3. themissile
    Member
    Posted 3 years ago #

    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.

  4. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

  5. kespinoza
    Member
    Posted 2 years ago #

    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. '"';
    }'

  6. kespinoza
    Member
    Posted 2 years ago #

    <?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. '"';
    }

Topic Closed

This topic has been closed to new replies.

About this Topic