zgall1
zgall1

Reputation: 3025

Removing the featured image from the post but leaving it on the index page

I have the following blog post index page. It loads a featured image before the text of the post.

On the post itself - I would like for the featured image to not load. I believe this involves editing this content.php file (attached here) but I cannot figure out how to do it such that the image loads only on the index page and not on the post page. Any help would be appreciated.

Upvotes: 0

Views: 123

Answers (3)

Dharmang
Dharmang

Reputation: 3028

You have to find all the occurrences of function the_post_thumbnail and remove them. Interesting files are:

  1. single.php
  2. page.php
  3. content.php
  4. content-gallery.php
  5. content-audio.php
  6. functions.php

Also check for get_the_post_thumbnail

Upvotes: 0

Kausha Mehta
Kausha Mehta

Reputation: 2928

Add the below code in place of the_post_thumbnail( 'serene-featured-image' ); at line no 24

Replace line no 24 with below code:

<?php 
    if ( ! is_single() ) :
        the_post_thumbnail( 'serene-featured-image' );
    endif;
?>

Upvotes: 1

Moeed Farooqui
Moeed Farooqui

Reputation: 3622

Comment out this code in your single.php (Deatil page of the Blog post)

<div class="main-image<?php if ( '' == get_the_post_thumbnail() && 'video' === get_post_format() ) echo ' et_video_only'; ?>">



<?php if ( 'video' === get_post_format() && false !== ( $first_video = et_get_first_video() ) ) : ?>
    <div class="et-video-container">
        <?php echo $first_video; ?>
    </div>
    <?php endif; ?>

    <?php if ( ! is_single() || ! 'video' !== get_post_format() ) : ?>
    <a href="<?php the_permalink(); ?>" class="et-main-image-link">
    <?php endif; ?>

        <?php the_post_thumbnail( 'serene-featured-image' ); ?>

        <?php serene_post_meta_info(); ?>

    <?php if ( isset( $first_video ) && $first_video ) : ?>
        <span class="et-play-video"></span>
    <?php endif; ?>

    <?php if ( ! is_single() || ! 'video' !== get_post_format() ) : ?>
    </a>
    <?php endif; ?>

</div> <!-- .main-image -->

Upvotes: 0

Related Questions