• Resolved forzaclaire

    (@forzaclaire)


    Hi I’m moving my blog from Independent Publisher 2 theme to Twenty Twenty and all has gone well except I’d like to have a header image on my post list but not on my posts (I’m using the “full width” template and having a header image doesn’t look good at all there).

    There was a “content option” for this in Independent Publisher where you chose where you wanted header images to appear (or not) but can’t find it on Twenty Twenty nor on “Options for Twenty Twenty” plug in and I’m not very good at coding (to say the least).

    Can anyone help ? Thanks!

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Anonymous User 14254218

    (@anonymized-14254218)

    According to the documentation of the function which determines whether a thumbnail exists or not, there is a filter you can apply.
    see: has_post_thumbnail

    You can use the has_post_thumbnail filter by pasting the following code into your functions.php file of the theme (best to create a child theme when editing the functions.php file.

    function has_post_thumbnail_ws21317($has_thumbnail) {
    	return !is_singular('post') && $has_thumbnail;
    }
    add_filter('has_post_thumbnail', 'has_post_thumbnail_ws21317');
    
    • This reply was modified 4 years, 7 months ago by Anonymous User 14254218.
    • This reply was modified 4 years, 7 months ago by Anonymous User 14254218.
    Thread Starter forzaclaire

    (@forzaclaire)

    Thanks @raqai — since I’m an amateur I was trying not to have to change anything in the theme code so that I could do without creating a child theme just for that (the rest is working fine), but I guess I’ll have to stop being lazy :p

    • This reply was modified 4 years, 7 months ago by forzaclaire.
    Anonymous User 14254218

    (@anonymized-14254218)

    you could also use css to achieve this. be aware though, that the featured image will still be loaded in the background using only css.
    Depending on your goals, both ways have their pros and cons. ??

    .post-template-default.single-post .featured-media {
        display: none;
    }

    Using the .post-template-default class if you only want to apply the changes to the default template. You can use .single-post or .singular while the former will hide the thumbnail only on single posts sites and the latter will also hide them on pages and custom post types.

    Usually I suggest using a child theme because it makes changing things way simpler. Considering you only need 2 files to create a valid child theme, the “overhead” is negligible since every change you make will most likely be future update proof because you do not actually change anything in the actual theme.

    • This reply was modified 4 years, 7 months ago by Anonymous User 14254218.
    Thread Starter forzaclaire

    (@forzaclaire)

    Child theme done and it works fine :-))) Thanks A LOT @raqai !

    Anonymous User 14254218

    (@anonymized-14254218)

    Glad I could help ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Header image’ is closed to new replies.