Skip

How I can give one page of a WordPress site different header content than the rest?
May 26, 2010 12:18 PM   Subscribe

How I can give one page of a WordPress site different header content than the rest?

I'm trying to help a friend tweak his WordPress-powered site, which you can see at nickwinnick.com, if you like.

As you'd expect, all the various pages (.../about/, ../blog/, ../services/, etc) have the same text in the header: Alacrity Editing | Editorial and publishing, yadda yadda.

So, Question: How can I make the page at ../blog/ have different text in it's header, like "Nick's Blog | Something, something...?

The desired text doesn't have to be dynamically generated from anywhere, I'm happy to hard-code it into a template. I'm just not clear on which theme files to modify, or perhaps not clear on how to modify them...

I have messed around customizing WP themes before, so you don't have to dumb-down any advice too much.

Thanks in advance for any help!
posted by chudmonkey to Computers & Internet (5 answers total) 4 users marked this as a favorite
 
Duplicate "page.php" in you theme and give it a suitable name.
Then add the following part to the top of the file
<> /*
Template Name: My Customs Page theme
*/
?>

Now you can remove the default get_header() and get_footer() functions from the file and format it as you need.

Then from the WP admin panel create a new page and select the "My Customs Page theme" from the dropdown menu in your right hand side.
posted by WizKid at 12:46 PM on May 26, 2010


It might be easier to use a conditional tag in the header, if the only difference is going to be a bit of text. Try starting with

if(!is_page() and !is_home()) { echo "blog header text"; }

as a starting point? You may have to do a whole bunch of !is_type stuff.
posted by epersonae at 12:52 PM on May 26, 2010


I have found creating custom theme page to be a better at keeping the code base clean. With the conditional method if you need a five different headers for five different pages that's going to be a whole bunch of conditional statements, which reduces the readability of the code.
posted by WizKid at 12:56 PM on May 26, 2010


Or, you could just use a plugin.
posted by jbickers at 1:04 PM on May 26, 2010


You could also do a conditional that if it's a page, the header displays the page title. That way, the about page would have different text in the header than the services page, etc.
posted by msbrauer at 6:47 PM on May 26, 2010


« Older What are the best tools to cre...   |  Where can I get unusual alphab... Newer »
This thread is closed to new comments.


Post