WordPress.org

Ready to get started?Download WordPress

Forums

Hiding Featured Image in TwentyTwelve Theme (15 posts)

  1. jkhnels
    Member
    Posted 1 year ago #

    Hey y'all!
    I am using TwentyTwelve on my site http://jkhnelson.com. 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!

  2. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    Copying the entire theme is not a child theme and your site is not currently using a child theme - see:

    http://codex.wordpress.org/Child_Themes

  3. jkhnels
    Member
    Posted 1 year ago #

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

  4. jkhnels
    Member
    Posted 1 year ago #

    Yes, I tried that. The directions are not clear on http://codex.wordpress.org/Child_Themes. 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 :)

  5. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    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:      http://example.com/
    Description:    Child theme for the Twenty Twelve theme
    Author:         Your name here
    Author URI:     http://example.com/about/
    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.

  6. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    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.

  7. jkhnels
    Member
    Posted 1 year ago #

    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: http://jkhnelson.com/
    Description: Child theme for the Twenty Twelve theme
    Author: Jen
    Author URI: http://jkhnelson.com
    Template: twentytwelve
    Version: 0.1.0
    @import url("../twentytwelve/style.css");
    */

    Is that correct placement of the parent CSS sheet?

  8. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

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

  9. jkhnels
    Member
    Posted 1 year ago #

    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?

  10. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    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.

  11. jkhnels
    Member
    Posted 1 year ago #

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

  12. jkhnels
    Member
    Posted 1 year ago #

    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.

    Thanks!

  13. Gary Allman
    Member
    Posted 1 year ago #

    @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.

  14. Emdad
    Member
    Posted 1 year ago #

    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.

  15. colleengreene
    Member
    Posted 1 year ago #

    @Gary Thank you for your solution. Worked great.

Topic Closed

This topic has been closed to new replies.

About this Topic