这是我用来检查自定义字段是否存在的内容。我相信你也可以用它。
<?php
$custom_field = get_post_meta($post->ID, \'Your Custom Field Name\', true);
// Checks to see if there is a value in the custom field
if($custom_field != \'\') { echo $custom_field; }
?>
上面的代码可能是这样的:
<ul>
<li><span class="icon" style="background-image:url(<?php
$custom_field = get_post_meta($post->ID, \'Your Custom Field Name\', true);
// Checks to see if there is a value in the custom field
if($custom_field != \'\') { echo $custom_field; }
?>);"> </span><a href="link">link</a></li>
</ul>