Support » Fixing WordPress » Remove Featured Image From Appearing Inside Post

  • Resolved candishidalgo

    (@candishidalgo)


    Featured image is needed for homepage, but I don’t want it to show inside the actual post.

    I’ve read to remove <?php if( has_post_thumbnail() ) : ?> from single.php, but this code does not exist in my single.php file.

    Here is the code for my single.php:

    <?php get_header(); ?>

    <div id=”content” class=”grid_10 <?php echo of_get_option(‘blog_sidebar_pos’) ?>”>

    <?php

    if (have_posts()) : while (have_posts()) : the_post();

    // The following determines what the post format is and shows the correct file accordingly
    $format = get_post_format();
    get_template_part( ‘includes/post-formats/’.$format );

    if($format == ”)
    get_template_part( ‘includes/post-formats/standard’ ); ?>

    <?php get_template_part( ‘includes/post-formats/related-posts’ ); ?>

    <?php comments_template(”, true); ?>

    <?php endwhile; endif; ?>

    </div><!–#content–>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Any ideas on how to accomplish this? Thanks for any help!

Viewing 15 replies - 1 through 15 (of 17 total)
  • Have a look at standard.php in includes/post-formats/ and you should find something like <?php the_post_thumbnail(‘thumbnail’); }?> which you can remove.

    That worked! I was beginning to lose hope. Thank you so much!

    Follow-up question:

    Now no images show on the “blog” page which displays all my recent posts, so it looks desolate without any pictures. Is there a way to keep the featured images on my blog page, but not have them show up inside the individual posts?

    I would try this code snippet where the thumbnail used to be:

    <?php
       if(!is_single()){
          if ( has_post_thumbnail()) { the_post_thumbnail('thumbnail');}
       }
    ?>

    So it will show the thumbnails everywhere except on a single post.

    Let me know if it works. Otherwise post the original standard.php file contents so I can see exactly where to fit this code.

    First of all – thanks for your continued help!

    That sort of worked… it added a small thumbnail instead of the larger featured image, which is actually fine with me, but it isn’t aligned to the left or right so it looks weird.

    Is there a way to either:

    – align the thumbnail to the left or right so the text wraps OR
    – make the image larger so it spans the width of the page and can sit just above the text excerpts

    See http://melissaberschauer.com/blog/ to see what I mean.

    Thanks so much for any help!

    Found a work-around, thanks!

    @candishidalgo.

    I’ve had a same problem. How did you solve the small thumbnail?

    @slaterbeckham, in case you are still having this problem, just today i edited the content.php file and removed below and it worked fine..

    <?php
    // Get, resize and display featured image
    if( of_get_option(‘blog_single_thumbnail’,’1′ ) == ‘1’ && has_post_thumbnail() ) { ?>
    <div class=”post-head-image”>
    <div id=”post-thumbnail”>
    <img src=”<?php echo aq_resize( wp_get_attachment_url( get_post_thumbnail_id() ), wpex_img( ‘blog_post_width’ ), wpex_img( ‘blog_post_height’ ), wpex_img( ‘blog_post_crop’ ) ); ?>” alt=”<?php echo the_title(); ?>” />
    </div><!– #post-thumbnail –>
    </div>
    <?php } ?>

    Just use a simple piece of CSS code:

    .thumbnail-div {
         display:none;
    }

    Hi,
    I do not have any reference to my thumbnail in my single.php file, but want to remove the featured images. Please help! Where can I edit, add code?

    The original issue happened because I added code in my functions.php that added featured images to all of my posts. However, after seeing how they look in the post, I HATE them. I deleted the code out of my fuctions.php, but it left all the images. How can I remove them without editing every single post? HELP PLEASE! I am using the Yoko theme. Here is an example of a post with the issue:
    http://www.thelawstudentswife.com/2013/09/pizza-dough/

    The blog I need help with is http://www.thelawstudentswife.com.

    Here is my content.php if that is helpful

    <?php
    /**
    * @package WordPress
    * @subpackage Yoko
    */
    ?>

    <article id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>

    <div class=”entry-details”>
    <?php if ( has_post_thumbnail() ): ?>
    “><?php the_post_thumbnail(‘thumbnail’); ?>
    <?php endif; ?>
    <p><?php echo get_the_date(); ?>
    <?php _e( ‘by’, ‘yoko’ ); ?> <?php the_author() ?>
    <?php comments_popup_link( __( ‘0 comments’, ‘yoko’ ), __( ‘1 Comment’, ‘yoko’ ), __( ‘% Comments’, ‘yoko’ ) ); ?></p>
    </div><!– end entry-details –>

    <header class=”entry-header”>
    <h2 class=”entry-title”>” title=”<?php printf( esc_attr__( ‘Permalink to %s’, ‘yoko’ ), the_title_attribute( ‘echo=0’ ) ); ?>” rel=”bookmark”><?php the_title(); ?></h2>
    </header><!– end entry-header –>

    <div class=”entry-content”>
    <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
    <?php the_excerpt(); ?>
    <?php else : ?>
    <?php the_content( __( ‘Continue Reading →’, ‘yoko’ ) ); ?>
    <?php wp_link_pages( array( ‘before’ => ‘<div class=”page-link”>’ . __( ‘Pages:’, ‘yoko’ ), ‘after’ => ‘</div>’ ) ); ?>
    <?php endif; ?>

    <footer class=”entry-meta”>
    <p><?php if ( count( get_the_category() ) ) : ?>
    <?php printf( __( ‘Categories: %2$s’, ‘yoko’ ), ‘entry-utility-prep entry-utility-prep-cat-links’, get_the_category_list( ‘, ‘ ) ); ?> |
    <?php endif; ?>
    <?php $tags_list = get_the_tag_list( ”, ‘, ‘ );
    if ( $tags_list ): ?>
    <?php printf( __( ‘Tags: %2$s’, ‘yoko’ ), ‘entry-utility-prep entry-utility-prep-tag-links’, $tags_list ); ?> |
    <?php endif; ?>
    “><?php _e( ‘Permalink ‘, ‘yoko’ ); ?>
    <?php edit_post_link( __( ‘Edit →’, ‘yoko’ ), ‘| <span class=”edit-link”>’, ‘</span>’ ); ?></p>
    </footer><!– end entry-meta –>
    </div><!– end entry-content –>

    </article><!– end post-<?php the_ID(); ?> –>

    Sam Demeda – where would that CSS code go?

    WPyogi

    (@wpyogi)

    Forum Moderator

    @thekentuckygent – CSS is theme/site specific, so unless you are using the same theme, unlikely to be relevant. This thread is also already marked resolved, so you should really start your own as per:

    http://codex.wordpress.org/Forum_Welcome#Where_To_Post

    Anyone else in this thread – please do so as well and also see:

    http://codex.wordpress.org/Forum_Welcome#Posting_Code

    I just wanted to thank @runningdeveloper up above so much. I used your first code to stop thumbnails from appearing in the post (along with the image!) and the 2nd code to add the code with the word single to add the thumbnails back in archives, search, categories.

    I thought this was a problem in the theme (White House) but in any case, fixed after months, thanks! http://donnabarstow.com/

    @thekentuckygent, I believe Sam’s code would just go in the Style page of the theme in the Editor. Better to have it with other thumbnail/image rules, but when I’m desperate, I just drop it in anywhere.

    I tried deleting snippets of code on the single portfolio php using the Virtue theme but I couldn’t get it to work. I ended up commenting out the one line that references $post_id = get_post_thumbnail_id() which seems to work.

    Snippet of code that was updated:

    <?php } else if ($ppost_type == ‘none’) {
    $portfolio_margin = “kad_portfolio_nomargin”;
    } else {
    // $post_id = get_post_thumbnail_id();
    $img_url = wp_get_attachment_url( $post_id);
    $image = aq_resize( $img_url, $slidewidth, $slideheight, true ); //resize & crop the image
    if(empty($image)) {$image = $img_url; }
    ?>

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Remove Featured Image From Appearing Inside Post’ is closed to new replies.