You can do something like this if you want it to apply to just single posts with post-type as post:
if ( has_post_thumbnail() ) {
if ( is_singular('post') ) {
the_post_thumbnail( 'story_thumb' );
} else {
the_post_thumbnail( );
}
}
or this if you want to check if the post is in a particular category.
if ( has_post_thumbnail() ) {
if ( is_singular('post') && in_category( 'category_slug' ) ) {
the_post_thumbnail( 'story_thumb' );
} else {
the_post_thumbnail( );
}
}
Where you replace category_slug with your category’s slug or an array of category slugs.
To use this in a function, you can define the custom function in your functions.php file as so
if ( !function_exists('my_custom_post_thumbnail') ) {
function my_custom_post_thumbnail() {
if ( has_post_thumbnail() ) {
if ( is_singular('post') ) {
the_post_thumbnail( 'story_thumb' );
} else {
the_post_thumbnail( );
}
}
}
}
Then replace the_post_thumbnail
in your theme with my_custom_post_thumbnail