Support » Themes and Templates » Hiding Featured Image in TwentyTwelve Theme

  • Hey y’all!
    I am using TwentyTwelve on my site I am trying to use the Featured Image to preset the post thumbnail for social sharing, since the thumbnails that Facebook etc picks are usually wrong.

    I found this code <?php if ( !is_single() ) the_post_thumbnail(); ?> that Gary provided here. Should that only go on the content.php document?

    I’ve created a child theme with just that change, but the thumbnails are still appearing when I ‘live preview.’ I basically copied the entire theme and made that one change on that document, but left the rest the same. Is there another change I need to make?

    This is my first attempt with a child theme, so I’m not sure if I am editing the correct part. Thanks!

Viewing 14 replies - 1 through 14 (of 14 total)
  • Copying the entire theme is not a child theme and your site is not currently using a child theme – see:

    I should add that my theme seems to always choose the last image in the post, even when pushing to Feedly, etc. And I would like to be able to select which image is used.

    Yes, I tried that. The directions are not clear on Hence why I am posting… I’m not a coder so I don’t understand which parts I need to create a child theme and change the way thumbnails/featured images are used.

    I also have not activated the child theme since it didn’t seem to do what I was looking for. I thought I would check my work first 🙂

    First get the child theme set up – reread that page – the child theme will start out with ONLY the style.css file in a new folder (child theme) in the themes folder.

    The new style.css file will contain only this:

    Theme Name:     Twenty Twelve Child
    Theme URI:
    Description:    Child theme for the Twenty Twelve theme
    Author:         Your name here
    Author URI:
    Template:       twentytwelve
    Version:        0.1.0
    @import url("../twentytwelve/style.css");

    Then activate that theme – make sure it’s working correctly. Then move on to modifying a template file.

    BTW, if you activate a child theme that’s a copy of the parent theme, having a duplicate functions.php file will crash your site – I would not recommend that.

    Thanks. Now it has overwritten the parent CSS so nothing is appearing correctly.

    Based on the Child Themes link above, I’ve done this:
    Theme Name: Twenty Twelve Child
    Theme URI:
    Description: Child theme for the Twenty Twelve theme
    Author: Jen
    Author URI:
    Template: twentytwelve
    Version: 0.1.0
    @import url(“../twentytwelve/style.css”);

    Is that correct placement of the parent CSS sheet?

    No, the @import line has to go below the comment tag (*/) – as is, it’s not being read.

    Ok thank you, that was not clear in the Child Theme directions.

    Now next question, where should I make an edit to remove the featured image from the post? I would like to have the same coding as Gary mentioned in this thread.

    When a post is summarized I want the featured image to show.
    When a post is displayed in full I don’t want the featured image to show.
    Using the following code seemed to do the trick:
    <?php if ( !is_single() ) the_post_thumbnail(); ?>

    As I intend to swap out my full posts for summary posts to encourage more click-through. Could you direct me on how to do that?

    According to that thread, you would make a copy of the content.php file in the child theme and on line 18 change this:

    <?php the_post_thumbnail(); ?>

    to this:

    <?php if ( !is_single() ) the_post_thumbnail(); ?>

    I have not tried or tested it and am about to get offline for several hours – but someone else may pick this up if need be.

    Thanks for your help. I will try adding the content.php file and see if that works.

    So I have updated my content.php file and uploaded it to my child theme, however it’s still showing the featured image above the post.

    Would anyone else be able to provide a little guidance on this? The child theme is active and I have updated all my settings to how they were in the parent them.


    @jkhnels: You’ve done a lot of these steps, I include them all for completeness for anyone else with the same query.

    1. Create a child theme
    2. copy the content.php file into it
    3. Open the content.php file for editing – which you can do from the WordPress dashboard. Appearance -> Editor content.php will be listed on the right.
    4. Find the line of code: <?php the_post_thumbnail(); ?>
    5. Replace it with: <?php if ( !is_single() ) the_post_thumbnail(); ?>

    If it still showing the featured image on single posts double check that the change has been made – and that you’ve edited the content.php of your child theme. The method I’ve outlined above is more reliable, because if you’ve accidentally put the content.php file in the wrong directory you won’t be able to find it to edit it! 🙂

    I’ve made a similar edit to my personal blog, where I’ve moved the thumbnail and made it smaller on summary posts.

    Hey jkhnels,

    Follow this complete process to accomplish your job.

    [modified – she HAS a child theme]

    4. Copy the content.php file from twentytwelve theme and paste it in your child theme folder

    5. Open the content.php file from WordPress Dashboard => Appearance => Editor => Content.php (Make sure you have activated your child theme first)

    6. Find this code <?php the_post_thumbnail(); ?> and

    7. Replace with

    <?php if( !(is_search() || is_archive() || is_category() || is_tag()) || is_home() ||  ) : ?>
    	<?php the_post_thumbnail(); ?>
    <?php endif; ?>

    8. Save it.

    9. Job done

    Code Explanation : Featured image will not display in search result, archive, category, tag and home page. But will be displayed in single post.

    @gary Thank you for your solution. Worked great.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Hiding Featured Image in TwentyTwelve Theme’ is closed to new replies.