I am using thumbnail on my blog posts. I added the following code in my functions.php for that purpose
add_theme_support('post-thumbnails');
set_post_thumbnail_size( 328, 228, true );
It's working fine and all thumbnails are 328 x 228
Now I want to change the thumbnail size only for a specific category ID is 9.
Post under category ID 9's thumbnails must be 100 x 150.
how can I do that?
I am using thumbnail on my blog posts. I added the following code in my functions.php for that purpose
add_theme_support('post-thumbnails');
set_post_thumbnail_size( 328, 228, true );
It's working fine and all thumbnails are 328 x 228
Now I want to change the thumbnail size only for a specific category ID is 9.
Post under category ID 9's thumbnails must be 100 x 150.
how can I do that?
Share Improve this question asked Jan 27, 2014 at 13:57 Riffaz StarrRiffaz Starr 7964 gold badges20 silver badges41 bronze badges1 Answer
Reset to default 2How about just use conditionals:
if ( in_category( '9' )) {
// different size for one category
set_post_thumbnail_size( 100, 150, true );
} elseif ( in_category( array( '5', '7' ) )) {
// different size for multiple categories
set_post_thumbnail_size( 150, 200, true );
} else {
// default size
set_post_thumbnail_size( 328, 228, true );
}
Reference:
- Conditional tags
- in_category