WordPress.org

Ready to get started?Download WordPress

Forums

Multiple Featured Images
Integrate into has_post_thumbnail (4 posts)

  1. xdecimos
    Member
    Posted 11 months 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 9 months 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 8 months 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 8 months 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.

Reply

You must log in to post.

About this Plugin

About this Topic