WordPress.org

Forums

Multiple Featured Images
Integrate into has_post_thumbnail (4 posts)

  1. xdecimos
    Member
    Posted 2 years ago #

    Hi

    I know that it should be pretty easy but how do I integrate the featured image to replace the normal "the_post_thumbnail"?
    I tried many stuff already but I'm pretty new with WordPress / PHP and couldn't figure it out.

    To fill in:

    if( class_exists( 'kdMultipleFeaturedImages' ) ) {
                kd_mfi_the_featured_image( 'featured-image-2', 'page', 'full' );
    }

    My current code:

    <?php if ( has_post_thumbnail() ) { ?>
    
        <div class="image"><a href="<?php the_permalink(); ?>">
    
          <?php the_post_thumbnail(generalimage); ?>
          </a></div>
    
        <?php }else{ ?>
    
        <div class="image"><a href="<?php the_permalink(); ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/nophoto.jpg"></a></div>

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

  2. J.D. Grimes
    Member
    Posted 1 year ago #

    <?php if ( has_post_thumbnail() ) { ?>

    Is equivalent to:

    <?php if ( (int) kd_mfi_get_featured_image_id( 'featured-image-2', 'page', 'full' ) != 0 ) { ?>

    Then replace this:

    <?php the_post_thumbnail(generalimage); ?>

    With this:

    <?php
    
    if( class_exists( 'kdMultipleFeaturedImages' ) ) {
                kd_mfi_the_featured_image( 'featured-image-2', 'page', 'full' );
    }
    
    ?>
  3. pha3z
    Member
    Posted 1 year ago #

    @ J.D. Grimes

    I think there is an error in your code above.

    <?php if ( has_post_thumbnail() ) { ?>

    is equivalent to:

    <?php if ( (int) kd_mfi_the_featured_image( 'featured-image-2', 'page', 'full' ) != 0 ) { ?>

    You used "get_featured_image_id", but I think you meant "the_featured_image" as I showed. They have different parameters.

  4. J.D. Grimes
    Member
    Posted 1 year ago #

    @pha3z - No, I meant get_featured_image_id, but I forgot to leave out the $size parameter, so it should be this:

    <?php if ( (int) kd_mfi_get_featured_image_id( 'featured-image-2', 'page' ) != 0 ) { ?>

    the_featured_image() would display the image, and we just want to check if it exists. The image would show in the wrong spot.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Multiple Featured Images
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic