Easiest PHP Help Ever! Take a Look!

ramtripper

BANNED
Joined
Jul 31, 2010
Messages
426
Reaction score
274
How do I make this function work without the "if" statement??

<?php if(get_post_meta($post->ID, 'my_post_image', true)): ?>
<img src="<?php echo get_post_meta($post->ID, 'my_post_image', true); ?>" alt=""/>
<?php else: ?>

<?php endif; ?>


Omg, i will love you for helping me with this. I know it's simple, im just not too familiar with php..

not exactly the same as excel.. LOL
 
Looks like Wordpress, um tried removing "if" before (get_post_meta...?

Then would need to remove <?php else: ?> assuming.

First glance, not exactly sure. Back up before trying. I can't see related files and functions.

EDIT: Could probaly remove first ( and last ) with my method also.
 
Last edited:
i dont know what kind of php this is but i would try this:

<img src="<?php echo get_post_meta($post->ID, 'my_post_image', true); ?>" alt=""/>
 
This is what I mean, replace (after backing up) and try.

<?php get_post_meta($post->ID, 'my_post_image', true): ?>
<img src="<?php echo get_post_meta($post->ID, 'my_post_image', true); ?>" alt=""/>

<?php endif; ?>
 
This is what I mean, replace (after backing up) and try.

<?php get_post_meta($post->ID, 'my_post_image', true): ?>
<img src="<?php echo get_post_meta($post->ID, 'my_post_image', true); ?>" alt=""/>

<?php endif; ?>

No if = no endif...
And i assume get_post_meta has a return value...
PHP:
<?php $pm=get_post_meta($post->ID, 'my_post_image', true); ?>
<img src="<?php echo get_post_meta($post->ID, 'my_post_image', true); ?>" alt=""/>
 
i havent try this yet..but

<img src="<?=(get_post_meta($post->ID, 'my_post_image', true))?get_post_meta($post->ID, 'my_post_image', true):"otherimage.jpg"?>">
 
No if = no endif...
And i assume get_post_meta has a return value...
PHP:
<?php $pm=get_post_meta($post->ID, 'my_post_image', true); ?>
<img src="<?php echo get_post_meta($post->ID, 'my_post_image', true); ?>" alt=""/>

Good point would result in a PHP error. Maybe removing endif would work, but heard that's a security issue in Wordpress? Unless in this case?

I'm really not good with Wordpress...maybe wkrappen91 knows better.

Which file is this even in Wordpress? We could see the code better as most would have it on our computers.

EDIT: Maybe he already posted the solution.
 
Last edited:
Good point would result in a PHP error. Maybe removing endif would work, but heard that's a security issue in Wordpress? Unless in this case?

I'm really not good with Wordpress...maybe wkrappen91 knows better.

Which file is this even in Wordpress? We could see the code better as most would have it on our computers.

EDIT: Maybe he already posted the solution.

wow, guys thanks a lot. I actually thought of a workaround for the theme im using.. it's really stupid they incorporated that piece in the theme, because it's supposed to be something like:

"if" u dont have image for rotating featured images - the sample image (a blank 600 by 300) will be there - thus the "else"

but I do have images - 4 of them in the featured area, and still the sample image shows up as a 5th.

it linked to the portfolio page of my theme, so what i did was make a featured portfolio image in photoshop as the 5th image, and now it makes sense and works smoothly.

Sorry for the trouble, but i really appreciate all your help guys!
 
Back
Top