• Resolved mesmer7

    (@mesmer7)


    I want to change the single post featured image to ‘medium’. I copied storefront_post_thumbnail() to my child theme’s functions file to override the parent theme function (removing the enclosing function_exists()), but it’s not having any effect.

    How can I override this function or set the post featured image to ‘medium’?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Jessica G.

    (@jesscga)

    Automattic Happiness Engineer

    Hey there!

    I copied storefront_post_thumbnail() to my child theme’s functions file to override the parent theme function (removing the enclosing function_exists())

    Can you share the code that you added to your child theme here so I can see how you’ve got it set up right now? We should be able to help work out any kinks once we have more info.

    Thread Starter mesmer7

    (@mesmer7)

    Hi Jessica. I did eventually figure this out. The code that didn’t work is:

    
    function storefront_post_thumbnail( $size = 'medium' ) {
        if ( has_post_thumbnail() ) {
            the_post_thumbnail( $size );
        }
    

    I’ve no idea why that didn’t work.

    But this is the code that solved my problem.

    
    add_filter( 'post_thumbnail_size', 'my_post_size' );
    function my_post_size( $size ){
       if (is_single()){
        return 'medium';
        }
        return $size;
    }
    
    Jessica G.

    (@jesscga)

    Automattic Happiness Engineer

    Super, I’m glad you got it working! I’ll close up this thread – please start up a new one if you have any other issues!

    Thread Starter mesmer7

    (@mesmer7)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘trying to override storefront_post_thumbnail()’ is closed to new replies.