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>
Thanks a lot !
I think this tip is useful for the magazine blog.
My site is also an magazine blog so I just need this tip.
i love this, thanks
Hi, can I show also a swf file?? I think yes, but I want to know your opinion before the creation of the flash file.
Thanks
Nick: Yes, you can. If you have different flash files for different pages of the website, you can use the same code but replace the name of the image with the name of the flash file (eg: instead of image_about.jpg, it will be about.swf). And then you will need to change your flash embed code (eg: swfobject) to use the variable that you specified.
Thanks man , i was looking for this !!!
.-= jean paul´s last blog ..Palais des thés =-.
This code is not working for my “blog” page…!!!! Why??? for other pages code is working as described.
Thank you so much!