Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable feature images on homepage only? #25

Open
kevquirk opened this issue May 24, 2020 · 3 comments
Open

Disable feature images on homepage only? #25

kevquirk opened this issue May 24, 2020 · 3 comments

Comments

@kevquirk
Copy link

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
Copy link
Author

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

@ndegruchy
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants