Delete post featured image with hooks

Hi there
I’d like to hide featured images from my posts using a hook not css.
Is this possible ? if it is, how ? thanks

Hi @vlad,

Thanks for writing us.

We dont recommend any modification at our theme files,
if you still want to do we suggest you to do at child theme.
For now our theme doesnot have any options to remove the featured image from posts.
The below code will work with the WordPress hooks only.
The following code will work if copied as it is and dont conflict with any existing codes.

add_filter( 'post_thumbnail_html', 'my_post_thumbnail_fallback', 20, 5 );
function my_post_thumbnail_fallback( $html, $post_id, $post_thumbnail_id, $size, $attr ) {
    if ( empty( $html ) ) {
        // return you fallback image either from post of default as html img tag.
    }
    return '';
}

Please note that the code provided serve only as a guide to help you get started custom coding on your own if there’s no option offered in our theme or the products we bundle. We do not provide support for custom codes that means we can’t fix it in case it conflicts with something in your site nor will we enhance it.

Hope it helps.

Thanks

thanks for your answer tristup. That’s what I exactly wanted . thanks

1 Like

Hi @vlad.

It’s our pleasure to help you.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.