susty icon indicating copy to clipboard operation
susty copied to clipboard

Disable feature images on homepage only?

Open kevquirk opened this issue 4 years ago • 3 comments

Hi,

I'm using an adapted version of this theme for my blog, and I would like to use feature images on occasion. However, I've configured the theme to only have a list of post titles on the homepage, not the excerpt.

So I would like to have the feature image hidden on the homepage, but displayed when navigating to the actual post.

I imaging there's some jiggery pokery to be done in the template-tags.php file, but I can't work out what it is.

If someone could help, I'd be ever so grateful.

Thanks!

kevquirk avatar May 24 '20 19:05 kevquirk

I've been able to do this in CSS, but I would prefer is the image wasn't loaded in the first place if possible.

Just in case I don't get a response, this is how I did it with CSS:

body.home .attachment-post-thumbnail {
    display: none;
}

kevquirk avatar May 24 '20 19:05 kevquirk

You could wrap the featured image output behind a check against is_home.

You could probably wrap the get_the_post_thumbnail in template-tags, specifically in here.

ndegruchy avatar May 25 '20 14:05 ndegruchy

Something like this:

    if(!is_home())
    { ?>
		<a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true">
			<?php
			the_post_thumbnail( 'post-thumbnail', array(
				'alt' => the_title_attribute( array(
					'echo' => false,
				) ),
			) );
			?>
		</a>
    <?php } ?>

ndegruchy avatar May 25 '20 15:05 ndegruchy