25 Jun, 2009
How to display a different header image for different pages in WordPress
Web Development » Snippets, WordPress, xHTML » How to display a different header image for different pages in WordPress
In header.php file of my WordPress theme, I have the following code to display a different header image for different pages.
<?php
if (is_page('about')) {
$image = 'image_about.jpg';
} else if (is_page('projects')) {
$image = 'image_projects.jpg';
} else if (is_page('services')) {
$image = 'image_services.jpg';
} else if (is_page('contact')) {
$image = 'image_contact.jpg';
} else {
$image = 'image_default.jpg';
}
?>
<div id="header">
<img src="<?php echo bloginfo('template_url'); ?>
/images/<?php echo $image;?>"
alt="<?php bloginfo('name'); ?>" />
</div>
Other similiar posts that you might be interested in:
- Customising category.php in WordPress
- 5 steps to creating a custom Archive page in WordPress
- Display 5 latest posts in each category in WordPress
- How to add a breadcrumb to your blog and have it appear on Google’s Search Result Snippet
- Golden Green WordPress Theme – Download
- Highlight the current page link in WordPress
- Building a real estate website using WordPress







