Jump to content

[SOLVED] wordpress and else if


Andrei

Recommended Posts

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 sub pages. scholarships-grants for example is a sub page (parent programs).

 

Hope someone can help. Not sure if this is the right place or if I should be in a wordpress help site.

 

Thank you for your time.

Link to comment
https://forums.phpfreaks.com/topic/152169-solved-wordpress-and-else-if/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.