WordPress.org

Ready to get started?Download WordPress

Forums

Multiple Featured Images
Conditionally Check (7 posts)

  1. welshhuw
    Member
    Posted 1 year ago #

    How can i run a conditional check on this?

    ie: If no Featured Image 2 is uploaded, then display the normal featured image instead.

    Thanks

    http://wordpress.org/extend/plugins/multiple-featured-images/

  2. thatwastaxing
    Member
    Posted 1 year ago #

    +1

  3. flint_and_tinder
    Member
    Posted 1 year ago #

    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>";
    }
    ?>
  4. flint_and_tinder
    Member
    Posted 1 year ago #

    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... ;-)

  5. flint_and_tinder
    Member
    Posted 1 year ago #

    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.

  6. flint_and_tinder
    Member
    Posted 1 year ago #

    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 } ?>
  7. Nephi
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.