I have an array as follows
<?php
$args = array(
"post_author_url" => "no",
"thumbnail_custom_field" => "image",
"post_include" => get_user_meta($userID, 'member_owner', true),
"layout_mode" => "multi_column","layout_num_cols" => "3");
special_recent_posts($args);
?>
This works great, but I want to have a Condition on one of the items
"thumbnail_custom_field" => "image",
The "image" might not exist so I need a fall back so it displays OK.
for example:
<?php if ( get_post_meta($post->ID, 'image', true)) {
echo 'image'
} else {
echo 'image-fallback'
?>
How can I have the image tag in the array set as a result of this IF statement? Do I make it a string before the array? or do I put the IF statement directly into the array? looking for a bit of expert guidance..thanks
Try the following:
The expression (expr1) ? (expr2) : (expr3) evaluates to expr2 if expr1 evaluates to TRUE, and expr3 if expr1 evaluates to FALSE. Lookup “Ternary Operator”.