PHP if this OR that

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
idesign123
Forum Newbie
Posts: 2
Joined: Fri Feb 25, 2011 3:28 pm

PHP if this OR that

Post 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:
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: PHP if this OR that

Post by Weirdan »

Code: Select all

if(get_post_meta($post->ID, 'audio', true) || get_post_meta($post->ID, 'video_embed', true)):
idesign123
Forum Newbie
Posts: 2
Joined: Fri Feb 25, 2011 3:28 pm

Re: PHP if this OR that

Post by idesign123 »

Perfect - thanks so much!
Post Reply