The code looks fine and you could just substitute page ids for the page titles.
http://codex.ww.wp.xz.cn/Conditional_Tags#A_PAGE_Page
You can find the individual page ids within the Admin/Pages. Place your cursor over a page title and look the url being displayed in the bottom left of your browser. It should end with &post=xxx. That xxx number is the page id.
I put the following code in my page.php page.
<?php if (is_page('21') ) {
$hdrimg = 'header-home.jpg';
} elseif ( is_page('26') ) {
$hdrimg = 'header-blog.jpg';
} elseif ( is_page('3') ) {
$hdrimg = 'header-photos.jpg';
} elseif ( is_page('30') ) {
$hdrimg = 'header-schedule.jpg';
} elseif ( is_page('32') ) {
$hdrimg = 'header-records.jpg';
} elseif ( is_page('34') ) {
$hdrimg = 'header-coaches.jpg';
} elseif ( is_page('36') ) {
$hdrimg = 'header-boosterclub.jpg';
} elseif ( is_page('38') ) {
$hdrimg = 'header-contactus.jpg';
} ?>
Using Firebug, it shows the the code below but the variable $hdrimg value is missing.
<img src="http://sanddsoft.com/images/"/>
Either I’m using the wrong page id’s or my links in the sliding header image links are not correct and perhaps I should link to the page ids.
Make sense?
My bad. Syntax error in this line.
<img src="<?php bloginfo('url');?>/images/<?php echo $hdrimg;?>"/>
I left out the ‘echo’ command. Oops. 😉
Works like a charm…almost.
Even though the ‘blog’ page is a page, it doesn’t seem to recognize that as a page in my if statements.
I’m having the same issue, where is_page isn’t working for my blog page. I would guess it is because it is not a page anymore and is instead now a ‘special’ page like front_page.
Turns out that is_home functions as is_blog when you have identified a static page to be the page where posts are displayed. So just use is_home.