如何设置if语句检查是否设置了图像

时间:2013-01-10 09:16:28

标签: php wordpress if-statement

我正在使用Word插件来设置2个精选图片以供发布。 我需要制作一个if语句来检查是否设置了第二个特色图像。 如果已设置,则将显示代码方案1。 但如果没有设置,如果没有设置,那么我需要显示代码方案2。

这是我需要检查的功能代码,这显示第二个图像。

<?php kd_mfi_the_featured_image( 'featured-image-2', 'post' ); ?> 

1 个答案:

答案 0 :(得分:1)

你应该使用kd_mfi_get_the_featured_image:

<?php if(class_exists( 'kdMultipleFeaturedImages') && kd_mfi_get_the_featured_image('featured-image-2','post')): 
?>
<!-- If the image exists... Your code here, either HTML or PHP -->
<?php else: ?>
<!-- If the image not exists... Your code here, either HTML or PHP -->
<?php endif; ?>