I saw some people looking to display a different image on each WordPress Page instead of the site wide random images. Read on…
First, I’ll give you the code and explain how it works. That way, you’ll understand it better and can easily adapt it to your site.
The Code
<?php if (is_page('28')) { ?>
<img src="<?php bloginfo('template_url'); ?>/headers/image1.jpg" width="920" alt="<?php bloginfo('name'); ?> header image" />
<?php } elseif (is_page('26')) { ?>
<img src="<?php bloginfo('template_url'); ?>/headers/image2.jpg" width="920" alt="<?php bloginfo('name'); ?> header image" />
<?php } elseif (is_page('30')) { ?>
<img src="<?php bloginfo('template_url'); ?>/headers/image3.jpg" width="920" alt="<?php bloginfo('name'); ?> header image" />
<?php } else { ?>
<img src="<?php bloginfo('template_url'); ?>/rotating.php?image=<?php echo mt_rand(0,100); ?>" width="920" alt="<?php bloginfo('name'); ?> Rotating Header Image" title="<?php bloginfo('name'); ?> Random Header Image" />
<?php } ?>
I have 3 Pages here. With the above code, I’m telling the theme to display a given image on each of those 3 Pages and to display random images everywhere else.
- 1st two lines tell the theme to display
image1.jpgon a Page with ID28. - next two lines tell it to display
image2.jpgon a Page with ID26and so on. - Last two lines (marked in blue) tell it to display random images everywhere else.
How to
- Upload your header images into the headers folder in your PrimePress directory.
- Open your
header-images.phpin your WordPress theme editor, delete the already existing code and paste the above code block in there. - Change the Page ID and the image file name according to your site. (parts marked in red)
Some Notes
Chances are, you want to do this on more than three pages. Just copy (duplicate) the lines marked in green, paste them right below (but above lines marked in blue) and change the ID and filename.
If you have permalinks turned on, you can also type in the post-slug in place of the Page IDs.

Hi Ravi, thanks for this informative post. I like this theme….very neat and your examples make modifications possible. I would like to try it on a new website…will let you know once its done.
Its nice theme. I installed it on my blog today. Thanks.
Thanks a lot Shankar…
Hi Ravi, I’m brand new to all this, but thanks for a beautiful, clean design. I want to use two different pages for two different blogs, and I’d like to be able to have a separate set of blogrolls on each page (and, ideally, separate tag clouds and categories). Is this possible?
Hi Sujata,
While I can not say its not possible, it becomes rather convoluted. I’d say the ideal way to maintain two blogs is to install two blogs and link them together.
Hi Ravi,
That’s great! Thanks for telling us how to do it.
Hi Ravi,
I just started a little blog to keep family and friends posted and I wanted to tell you that I must have looked at nearly 100 themes and for whatever reason kept coming back to this one. It is nice and clean; easy on the eyes. I just need to get around to changing the pictures and it is good to go!
I also wanted to let you know that I found that article (I guess the only one up) on your TechTrot site useful for someone starting out. You should write a little more often over there.
Cheers,
Jose
[...] WordPress Page specific Header Images – PrimePress Theme for WordPress [...]
Ravi,
Very nice use of the switch. I think this is what I need, here is what I want to do. On my contact form page ( plugin used for form ) I want to add an image to the page. If i put the php for the image in my ( page.php ) file it shows up on all pages. I just want it on the contact page. ALSO, in WordPress 2.7 page id’s are not listed in Admin Edit pages.
Thanks for any info that might help.
Jim
Very nice use of the switch. I think this is what I need, here is what I want to do. On my contact form page ( plugin used for form ) I want to add an image to the page. If i put the php for the image in my ( page.php ) file it shows up on all pages. I just want it on the contact page. ALSO, in WordPress 2.7 page id’s are not listed in Admin Edit pages.
Sorry-forgot to say. As you mentioned above might be easier to use slug (contact) since page id’s are not displayed any longer. My image path is ( images/logo.png)
Thanks
JIM
This codes which i’ve been looking for, thanks Ravi
WOW that code is extremely simple thanks so much.
i use it but have some troubles with colors identification =((
Great work!
Was asked if I could add this feature to a site today, obviously I said “of course” but had no idea how I was going to do it!
Many thanks
Hello:)
That post solve my problem – thanks a lot:)
Best Regards
Yeah, now it is understandable … And then I just not even know where it is not us with the title …
Hello!
Very Interesting post! Thank you for such interesting resource!
PS: Sorry for my bad english, I’v just started to learn this language
See you!
Your, Raiul Baztepo
Very nice use of the switch. I think this is what I need, here is what I want to do. On my contact form page ( plugin used for form ) I want to add an image to the page. If i put the php for the image in my ( page.php ) file it shows up on all pages. I just want it on the contact page. ALSO, in WordPress 2.7 page id’s are not listed in Admin Edit pages.
Thanks for any info that might help.
I’m trying to set up the blog so a specific image always shows up on each page, and used your code for doing this. Problem is, I can’t find how the home page is labeled… it doesn’t show up on the “Edit Pages” page… How would I find this out? I’ve tried all possible permutations (index, home, homepage, default, etc).
Put the images into a subfolder in the headers folder
headers/pages/image-home-page.gif
headers/pages/image-contact-page.gif
etc
this keeps them out of the rotation images, which only looks in the main ‘headers’ folder not subfolder.
So you can choose which pages for individual images, and have 1 in rotating images ‘headers’ folder; or 4 or whatever, as the default for ‘general’ pages.
Thanks
а вот вопросик можно? У вас время после поста указано. Это московское? Заранее спасибо!
helped me very much. thanks
The forum is a brgheitr place thanks to your posts. Thanks!
8Ea69K vpiwycovyptl
OMA6yU hnyvbjnjiuhr
Мне нравятся Ваши посты, заставляет задуматься…
не информативно как- то
большое спасибо!Взяла себе тоже-пригодится.
Мне кажется очень хорошо
Мне кажется ништяк!
Опубликовал на своем блоге вашу статью, и напечатол там конечно-же обратную ссылку на вас. Но вот зашел посмотреть поевился ли трекбек, а его нет…
[...] * WordPress page specific header images [...]
Finally! Someone with a little know-how! Thank you so much for this post.
[...] on the header and other post pages, but on individual pages as well), I came across this post from Ravi Varma. It helped me do exactly what I wanted and it was super-easy too! Here’s how you change an [...]
this is great but I can only get it to work on pages like is_home and is_search, giving ids just doesn’t show the images or even a placeholder, can you help?
И как же это можно понять простому человеку?
Тяжело в учении – легко… в учебном бою.
Голова трещит. Следует что-либо предпринимать в своем бизнесе. Да и грядущая перерегистрация ООО – очень актуальная тема на сегодняшний момент. Не профукать бы. Проблему необходимо решить за полгода. Крамбец.
Горы мусора ещё не баррикады, – СВОБОДЫ не хватает!
Отличный пост. Я вот тоже хочу поделиться полезной ссылкой. Тут можно скачать программу. Так что заходите – не пожалеете.
Складно пишете. Но не пойму почему изложеный материал вызвала воспоминания о детстве, и не отходя от темы – Детские Игрушки Москва. И не забрасывайте блог; )
Do you want know your dns records tools?
Cool servise – My-Addr Project
Thanks for the fascinating code and steps! I have been searching for this for almost 2 hours now, thanks.
Regards,
Jermaine
Hi Ravi,
Thanks for a great theme! I wanted to know if it is possible to adapt this function to create page specific banners in the wide sidebar? And if it is possible to add links to them as well?
Any advice would be much appreciated.
Thanks,
Aaron
I sure wish someone would write a plug in to add this functionality.
I think I’m going to have to tackle that…
[...] * WordPress page specific header images [...]
Hey, you must see that – replica tag heuer
I’m very green at this. Can you tell me how to upload the header images? Thnx!
thank you very good
Смотреть фильмы онлайн
They scream at each other, exchange racial epithets, and, in some cases, incite fights. ,
Even though members can be academic experts and researchers, Yahoo! ,
Change the Page ID and the image file name according to your site. (parts marked in red)
what is page id?
Big thanks…)
Thanks!) good site..
Thanks for the fascinating code and steps! I have been searching for this for almost 2 hours now, thanks.
Hi Ravi… Excellent post, but I have a little question:
Could I replace this on this to specify a concret category where I need to show a specific image. Thanks a lot man!
Текст реально понравился. Автору респект и уважуха. В поддержку темы тоже делюсь тем, что близко мне – Скандальные новости мира, Заходите – не пожалеете
Very smart post! Thank you!
YRSS
You must see that – dumps
Думаю всем читателям этого ресурса будет полезна следующая ссылка – болезни поджелудочной железы
thnx admn
thank you admn
Thanks for the advice, brilliant
this is the best site for machines
asdasdas
thanks for your information…
I use this theme in my blog —-> www. redtor. com
Hi admin,
That’s great Theme! It’s Easy to use and I use this theme in my blog…
скачать сериалы
kluchi
аквариумы
Thanks! good site.. Good Theme!
A big thank you for the information
thanks for useful and meaningful article…:
Thanks Ravi for this great tip. I really like your theme and I’ve used it a few times. Can this technique be used in sidebar ads as well?
where is the header folder in primepress directory???
I have used the same thing to change the banner images for different pages and they are changed also but for particular one page which has job board plugin and is also based on separate template page rather than default template,for it I am not able to change its banner. It is showing the default banner which I have used in else statement
Hey guys,
For everyone looking for the solution to the home page, this is what I did.
<img src="/headers/image1.jpg” width=”920″ alt=” header image” />
I changed that to:-
<img src="/headers/image1.jpg” width=”920″ alt=” header image” />
That’s it. Hope that helps someone.
<img src="/headers/image1.jpg” width=”920″ alt=” header image” />
change to:-
<img src="/headers/image1.jpg” width=”920″ alt=” header image” />
*please remove spaces between the < & ?
Shit, I can’t post php here, but basically you need to change the first line of code from if is_page to is_home and that’s it.
thank you now i had only a problem in te POST the hedler is broken can you help me?? Thanks
Вполне, ч0ткая новость
Не помню где я уже читал близкую инфу да ладно
Писака респект
Hi Ravi, thanks for this informative post. I like this theme….very neat and your examples make modifications possible. I would like to try it on a new website…will let you know once its done.
Отдых в турции с детьми; Безупречно о отдыхе на крите.
Shit, I can’t post php here, but basically you need to change the first line of code from if is_page to is_home and that’s it.
Hi , Thanks very good logo tasarım , puna , kısmetim 2follow me web sites . Thank you
I am very happy I found this article. Thanks for the post!
Great post also! Your writing is so fresh in comparison to most other bloggers. Thanks for writing when you get the chance to, I’ll be sure to keep visiting!
Thanks
Md.Alamin Khan
Great article on social media. This article points out some good information about how social media is a big factor on business
Thanks
Liton mia
Your article seems interesting, i have noted it my digg and stumble account.The point you are making is easy to understand and effective. I have blog site for SEO, Art,Shopping.
Thanks
bivian tilma
Hello there ,
this is a very interesting article. I tell you that the subject is more profound that appear. Believe me !!! Very good site.Keep it up.I liked the look and feel of ur site. . I have many blog site for Link, directory,Hosting
,Sports and much more.
Best of luck
Romel Naan
> Ellis Benus posted on July 17, 2009 at 12:51 pm:
> I sure wish someone would write a plug in to add this functionality.
> I think I’m going to have to tackle that…
Well, good job core WordPress team.
Автор перспективный мужик
Чего и следовало ожидать, тот кто писал убого опубликовал.
I am going to give it a try, I will use that switch on my theme
Thanks a log Ravi
Thanks! good site.. Good Theme!
Your article seems interesting. Thank you very much.
Мысль никогда не должна подчиняться ни догме, ни направлению, ни страсти, ни интересу, ни предвзятой идее, ни чему бы то ни было, кроме фактов, потому что для нее подчинится — значило бы перестать существовать.
Квартиры в Москве от застройщика – это наиболее популярный и выгодный вариант при покупке жилья на сегодняшний день. Готовые квартиры в новостройках Москвы – это дома, построенные совсем недавно.
I am going to give it a try, I will use that switch on my theme
I will use that switch on my theme
thank you very good nice works good
Владимирская мебель диваны дешево МСК и МО
theme colors and a very good initiative. You know google argoritmasına new understanding and appropriate
WOW that code is extremely simple thanks so much.
thanks buddy… code is succesfully runing…. keep rockin…
Хороший блог, только вот шрифт слегка напрягает глаза при чтении, но в целом немало времени провёл здесь, добавил в закладки
Your article seems interesting. Thank you very much.
Thank you for this code.
I would appreciate your comment on this:
Header graphics are perhaps not as important on a website as they once were?
I know this may appear to be controversial, but I believe that we are now seeing a trend that we have not seen before. Do you agree or disagree? I am not changing the subject it just that I think we need to expand the conversation.
Thanks a Lot Mr. Ravi Sharma…Vry Nice Article ..Keep it Up
Аквариумы
would appreciate your comment on this:
Can you help me set this up