Want featured image to appear on blog homepage but not on post

  • Unknown's avatar

    Hello,

    Some of my images are smaller than the 2000 x 1500 px suggested size for featured images, so while I’d like these images to appear next to each post on my blog homepage, I don’t want them to display as a featured image (with the full width of the screen on the post.

    Is there a way to have the featured image display on the blog homepage but be suppressed on individual posts?

    Thanks very much.

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar

    Moving this to the Themes forum for organization. :)

    Since yours is a self-hosted website, I’d recommend making this change in your child theme. Open up the file ‘content-single.php’ and you’ll see some code that begins with this:

    <?php
    /**
     * @package Resonar
     * @since Resonar 1.0
     */
    ?>
    
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    	<?php
    		if ( has_post_thumbnail() && ! post_password_required() ) :
    			$featuredimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'resonar-large' );
    	?>
    		<div class="entry-header-background" style="background-image:url(<?php echo esc_url( $featuredimage[0] ); ?>)">
    			<div class="entry-header-wrapper">
    				<header id="entry-header" class="entry-header">

    and so on.

    Focus just on line 13:

    <div class="entry-header-background" style="background-image:url(<?php echo esc_url( $featuredimage[0] ); ?>)">

    remove that style rule, so it looks like this:

    <div class="entry-header-background">

    And save your child theme.

    Resonar will stop loading the featured image onto your single-post page.

  • The topic ‘Want featured image to appear on blog homepage but not on post’ is closed to new replies.