How to add-image-size by category?
-
I’m trying to figure out how to apply suggested snippits in the forums for the purpose of setting a new image size or “add-image-size,” based on a category.
Four years ago, keesiemeijer answered the question for a previous inquiry thus:
In your theme’s functions.php:
if ( function_exists( 'add_image_size' ) ) { add_image_size( 'category-thumb', 300, 9999 ); }
and this in your theme’s template files (inside the loop):
if ( has_post_thumbnail() ) { if (is_category('3')){ the_post_thumbnail( 'category-thumb' ); }
}
- Do I need to add_action(‘after_setup_theme’,’themeic_thumb_sizes’); in functions first?
-
I have categories for both media a posts. Which category should I use?
Am I correct to assume the the “is_category” refers to media category?-
Can I use “catalog” as the name or must I use “category-thumb” in this example? I assume I can still add “true” for a crop?
-
What and where is the loop?
-
If there are more current instructions to set image size based on category, where might I find them?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How to add-image-size by category?’ is closed to new replies.