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

Php 如何使用if语句检查是否设置了图像,php,wordpress,if-statement,Php,Wordpress,If Statement,我正在使用Word press的插件为帖子设置2个特色图片。 我需要做一个if语句来检查是否设置了第二个特征图像。 如果已设置,则将显示代码场景1。 但是如果没有设置,如果没有设置,那么我需要显示代码场景2 这是我需要检查的功能代码,显示第二幅图像 <?php kd_mfi_the_featured_image( 'featured-image-2', 'post' ); ?> 您应该使用kd_mfi_获取特色图像: <?php if(class_exists( 'kdMu

我正在使用Word press的插件为帖子设置2个特色图片。 我需要做一个if语句来检查是否设置了第二个特征图像。 如果已设置,则将显示代码场景1。 但是如果没有设置,如果没有设置,那么我需要显示代码场景2

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

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

您应该使用kd_mfi_获取特色图像:

<?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; ?>


您是否尝试过这么简单的方法:…?我不认为workedParse错误:语法错误,意外的'@JohnFloyd',可能是您将HTML粘贴到其中,或者是另一个打开的yea,我正在尝试检查图像是否已设置。如果没有设置,那么我需要显示两种不同类型的htmlcode@JohnFloyd我已经更新了示例。在IF子句中,输入要在图像存在时显示的代码。在下面,你做你的退路。