我在WordPress中有一個名爲「thumb-url」的自定義字段,其中包含圖像的確切位置。我只想如果「thumb-url」包含圖像的位置,則顯示圖像。回聲包含PHP的字符串(在WordPress中)
如果在「thumb-url」自定義字段中存在值,則我會從if語句開始回聲照片存在否則它什麼也不做。
<div class="excerpt">
<?php
$key = 'thumb-url';
$themeta = get_post_meta($post->ID, $key, TRUE);
if($themeta != '') {
echo 'photo exists';
}
?>
現在,這裏是我真正想要的上方,如果回聲聲明,如果有在「拇指URL」的值代碼:
<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語句?
非常感謝......
我可以把IMG + PHP標記到一個新的.php文件幷包含php文件? – 2009-12-08 17:47:27
你......對我而言......儘管它不是超高效的,但它現在起作用。 – 2009-12-08 17:50:34