Page 1 of 1

PHP if this OR that

Posted: Fri Feb 25, 2011 3:32 pm
by idesign123
I'm very new to PHP and am trying to write a code snippet for a Wordpress website.

The current (working) PHP code is the following...

Code: Select all

<?php if(get_post_meta($post->ID, 'audio', true)): ?><img src="http://www.website.com/images/home/icon.gif" alt="" border="0"><?php endif; ?>
I need to change it so that the code so the image shows if EITHER the 'audio' or 'video_embed' fields are present. Here is my (nonworking) attempt...

Code: Select all

<?php if(get_post_meta($post->ID, 'audio', true) || ($post->ID, 'video_embed', true)): ?><img src="http://www.website.com/images/home/icon.gif" alt="" border="0"><?php endif; ?>
Do you see what I did wrong?
Or is there a better way to write this?

Thanks so much :wink:

Re: PHP if this OR that

Posted: Fri Feb 25, 2011 3:52 pm
by Weirdan

Code: Select all

if(get_post_meta($post->ID, 'audio', true) || get_post_meta($post->ID, 'video_embed', true)):

Re: PHP if this OR that

Posted: Fri Feb 25, 2011 4:24 pm
by idesign123
Perfect - thanks so much!