php else if for child pages
-
I’m trying to display a different header on each separate page on my site using this code:
<?php if (is_page(about)) { ?> <img src="<?php bloginfo('url'); ?>/wp-content/uploads/2009/03/homepage2.jpg" /> <?php } else if (is_page(programs)) { ?> <img src="<?php bloginfo('url'); ?>/wp-content/uploads/2009/03/homepage2.jpg"> <?php } else if (is_page(calendar)) { ?> <img src="<?php bloginfo('url'); ?>/wp-content/uploads/2009/03/calendar.jpg"> <?php } else if (is_page(donate)) { ?> <img src="<?php bloginfo('url'); ?>/wp-content/uploads/2009/03/donate.jpg"> <?php } else if (is_page(endangered-treasures)) { ?> <img src="<?php bloginfo('url'); ?>/wp-content/uploads/2009/03/endangered.jpg"> <?php } else if (is_page(scholarships-grants)) { ?> <img src="<?php bloginfo('url'); ?>/wp-content/uploads/2009/03/scholarships.jpg"> <?php } else if (is_page(sustainable-purchasing)) { ?> <img src="<?php bloginfo('url'); ?>/wp-content/uploads/2009/03/sustainable.jpg"> <?php } else if (is_page(forum)) { ?> <img src="<?php bloginfo('url'); ?>/wp-content/uploads/2009/03/sustainable.jpg"> <?php } else { ?> <img src="<?php bloginfo('url'); ?>/wp-content/uploads/2009/03/homepage2.jpg">
There are two problems. First of all, it seems to ignore the final else statement and instead shows endangered.jpg. Second, it seems to ignore child pages. scholarships-grants for example is a child page (parent programs).
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘php else if for child pages’ is closed to new replies.