if… elseif… else… I am lost.
-
Hello everyone,
I am trying to set up a special mechanism on my home page that will show an image if a custom field is defined, that will show another image — a default one — if no custom field is defined, and finally that will show nothing if not on the home page.
I must be doing something wrong here cause it will not work. Can someone check the code please?
Also, i do not know the PHP trick to “display nothing”, or just “do nothing”.
Here is the code:
<div id="latest-post-image"> <?php if (get_post_meta($post->ID, 'latest_home_img', true) && (is_home()) ) { ?> <a href="<?php printf(__ ('Permanent Link to %s', 'sandbox'), get_the_title() )?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/latest/<?php echo get_post_meta($post->ID, "latest_home_img", $single = true); ?>" alt="<?php bloginfo('name'); ?>: Latest post" /></a> <?php } else if (get_post_meta($post->ID, 'latest_home_img', false) && (is_home()) ) { ?> <img src="<?php bloginfo('stylesheet_directory'); ?>/images/latest/magpie_default.png" alt="<?php bloginfo('name'); ?>: Image ordinaire" /> <?php } else { (get_post_meta($post->ID, 'latest_home_img', false) && (!is_home()) ) ?> "Diplay noting, niet, rien du tout" <?php } ?> </div><!-- /.latest-post-image -->
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
The topic ‘if… elseif… else… I am lost.’ is closed to new replies.