Front-end Web Developer | Tampa, FL

How to create different image (style) header on different pages in WordPress?

Posted on: February 22nd, 2010 by admin No Comments

Open folder: wp-content/themes/YourThemeName/header.php and add this code to the bottom:

{CODE type:php;}
<?php if(is_page(‘Services’)) :?>
<img src=”<?php bloginfo(‘template_url’); ?>/images/services.png” alt=”Services”/>
<?php endif;?>

<?php if(is_page(‘Portfolio’)) :?>
<img src=”<?php bloginfo(‘template_url’); ?>/images/portfolio.png” alt=”Portfolio”/>
<?php endif;?>

<?php if(is_page(‘Contact’)) :?>
<img src=”<?php bloginfo(‘template_url’); ?>/images/contact.png” alt=”Contact”/>
<?php endif;?>

<?php if(is_page(‘Blog’)) :?>
<img src=”<?php bloginfo(‘template_url’); ?>/images/blog.png” alt=”Blog”/>
<?php endif;?>

What we have in this code: is_page(‘Services’) where Service is the name of Service page, you can use ID’s of your pages: is_page(’43’).

bloginfo(‘template_url’) this is path to Your theme, WordPress adding this automatically.

Thanks, Vlad.

Comments are closed.