我在 WordPress 中有一个名为“thumb-url”的自定义字段,其中包含图像的确切位置。如果“thumb-url”包含图像的位置,我只想显示图像。
我从 if 语句开始,如果“thumb-url”自定义字段中有值,则回显photo 存在,否则它什么也不做。
<div class="excerpt">
<?php
$key = 'thumb-url';
$themeta = get_post_meta($post->ID, $key, TRUE);
if($themeta != '') {
echo 'photo exists';
}
?>
现在,如果“thumb-url”中有值,这是我真正希望上述 if 语句回显的代码:
<img alt="<?php the_title() ?>" src="<?php if ( function_exists('get_custom_field_value') ){ get_custom_field_value('thumb-url', true); } ?>" align="absmiddle" height="62" width="62" class="writtenpostimg" />
如何在 if 语句的 echo 部分获得 ↑ ?
非常感激...