Support » Plugin: Multiple Featured Images » [Plugin: Multiple Featured Images] Conditionally Check

Viewing 6 replies - 1 through 6 (of 6 total)
  • +1

    I’m nearly there. I’m playing around with this but it’s not quite right. Perhaps this is a springboard for someone who actually knows php? 😉

    <?php
    if(kd_mfi_get_the_featured_image('web-featured', 'projects')) {
    	$slider1 = "kd_mfi_the_featured_image( 'web-featured', 'projects', 'large' );";
    	echo "<li>$slider1</li>";
    }
    ?>

    Obviously my code doesn’t have a fallback, but surely you should be able to add in an else to my if?

    Once my if works… 😉

    a-ha! I have managed to get my code to work like so:

    <?php if (class_exists( 'kdMultipleFeaturedImages') && kd_mfi_get_the_featured_image('web-featured', 'projects')) { ?>
    <li>
    	<?php kd_mfi_the_featured_image('web-featured', 'projects' );?>
    </li>
    <?php } ?>

    Therefore surely you should be able to add an else statement to that giving you a fallback image. I think.

    I also think I should learn php.

    I can confirm that an else statement will work like so:

    <?php if (class_exists( 'kdMultipleFeaturedImages') && kd_mfi_get_the_featured_image('logo-featured', 'projects')) { ?>
    <li>
    	<?php kd_mfi_the_featured_image('logo-featured', 'projects' );?>
    </li>
     <?php } else { ?>
     <img src="<?php bloginfo('template_directory');?>/images/link-plus.gif" width="9" height="9" />
    <?php } ?>

    Thanks so much for responding to your own question with your solution, you’re a star 🙂

    I’m still using the default names and it looks like this.

    <?php if (class_exists( 'kdMultipleFeaturedImages') && kd_mfi_get_the_featured_image( 'featured-image-2', 'post' )) { ?>
    
    	<?php kd_mfi_the_featured_image('featured-image-2', 'post' );?>
    
     <?php } else { ?>
    
     <img src="<?php bloginfo('template_directory');?>/images/defaultthumb2.jpg" />
    
    <?php } ?>
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Multiple Featured Images] Conditionally Check’ is closed to new replies.