apa@imagix.dk
Member
Posted 3 years ago #
I use this line to display a custom field (photograoher) on single.php...
<?php $key="photographer"; echo get_post_meta($post->ID, $key, true); ?>
Say the custom field "photographer" has not been added to a specific post. Is there anyway to just display a standard text then - "Not known" or something like that?
Regards,
Anders
Something like:
<?php
$key="photographer";
$custom=get_post_meta($post->ID, $key, true);
if ($custom) {
echo $custom
} else {
echo 'Not known';
}
?>
apa@imagix.dk
Member
Posted 3 years ago #
That returns an error... Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home...
Oops, forgot a ;
<?php
$key="photographer";
$custom=get_post_meta($post->ID, $key, true);
if ($custom) {
echo $custom;
} else {
echo 'Not known';
}
?>
apa@imagix.dk
Member
Posted 3 years ago #