PHP if/else problem – executing code?
-
I’m using the following code to determine whether a books it out of print – it corresponds to a checkbox on the backend. I want to execute a piece of code in the ‘else’ section but can’t get it to work.
The code is this:
<?php if ( get_post_meta($post->ID, 'out_of_print', true) ) { echo "Currently out of print"; } else { echo ""; } ?>
The code I want to execute on ‘else’ is a linked image file, eg:
<a href="<?php echo get_post_meta($post->ID, 'link', true); ?>"><img src="imagefilelink"></a>
I can’t get this to work at all, having inserted the code in many different places – it just seems to crash the code.
Thanks
- The topic ‘PHP if/else problem – executing code?’ is closed to new replies.