homepage Welcome to WebmasterWorld Guest from 54.197.171.109
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / WordPress
Forum Library, Charter, Moderators: lorax & rogerd

WordPress Forum

    
How can i ADD different header on each page on wordpress?
ADD different header on each page on wordpress?
ansokclifford




msg:4400049
 10:45 am on Dec 21, 2011 (gmt 0)

I just wondering if i can put different header on each page?

This is my sample site and i'm using a plugin Header Slideshow SampleSites/

is it possible?

your response would help resolve my problem

Thanks in advance :)

 

rocknbil




msg:4400186
 4:33 pm on Dec 21, 2011 (gmt 0)

$someheader = 'this-page-header';
// Or some logic that sets $someheader based on the page

get_header($someheader);

A less graceful way to go about it (as far as programming) - but would give you more control from the admin interface - is to create a custom field that sets what header to use. If you don't set it, it uses the default header.

So let's say in custom fields you create a field 'custom-header' and set the value 'third-page'. Wordpress looks for files that begin with 'header', so this would turn into 'header-third-page'.

$check_custom = get_post_meta(get_the_ID(),'custom-header',1);
$this_header = (! empty($check_custom))?'header-' . $check_custom:null;

get_header($this_header);

So for no custom field value you get the standard

get_header()

for a page with "third-page" set for the custom-header field you get

get_header(header-third-page);

(quoting is not necessary for variables but if you DO quote, use double quotes, not single quotes, or the variable won't interpolate.

get_header("$this_header");

)

ansokclifford




msg:4400481
 12:12 pm on Dec 22, 2011 (gmt 0)

thanks man

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / WordPress
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved