Title: Multiple php the_post_thumbnail sizes
Last modified: August 20, 2016

---

# Multiple php the_post_thumbnail sizes

 *  [alanpeto](https://wordpress.org/support/users/alanpeto/)
 * (@alanpeto)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/multiple-php-the_post_thumbnail-sizes/)
 * Couldn’t find this answer in the forum, so hopefully this is easy enough to do.
   Basically I would like to have two different sizes available for the ‘featured
   image’. The only time I will use the other is when my featured image is an infographic,
   for example. All other times, the default size/crop is just fine.
 * OK, my theme has the following size in functions for the featured image:
 * `add_image_size( 'single-large', 564, 272, true ); // Single post/page large`
 * and appears in single.php as
 * `<?php the_post_thumbnail('single-large'); ?>`
 * which is fine (and I’d like to keep all other posts just like this except those
   that need this other size). But I need just one more size available for ones 
   that need to be longer height. Is this possible?
 * I know I can ‘insert’ an image, but that won’t make it a featured image and it
   won’t appear as a thumbnail on the homepage or categories.
 * I’ve added a new image size of:
 * `add_image_size( 'single-large-graphic', 564, 1000, true );`
 * but not sure how to make that an additional option for a featured image should
   I want it for a specific image/post.
 * Any ideas? Thank you to the coders out there 🙂 🙂

Viewing 14 replies - 1 through 14 (of 14 total)

 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/multiple-php-the_post_thumbnail-sizes/#post-2511115)
 * [Post_Thumbnails](http://codex.wordpress.org/Post_Thumbnails)
    scroll down, it
   has info which pertains to this:)
 *  Thread Starter [alanpeto](https://wordpress.org/support/users/alanpeto/)
 * (@alanpeto)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/multiple-php-the_post_thumbnail-sizes/#post-2511122)
 * Thanks deepbevel! I looked through it, but it looks like what I already have??
   Is there a specific portion I should be looking at?
 * I already have functions.php specify the two versions of the image sizes I want.
   But how do you specify on single.php which one you want? When you add a featured
   image to the post, it doesn’t give you the option to specify…but inserting an
   image does (but that doesn’t make it a featured image).
 * I’m lost 🙂
 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/multiple-php-the_post_thumbnail-sizes/#post-2511126)
 * maybe you could use either conditionally by category or tag.
 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/multiple-php-the_post_thumbnail-sizes/#post-2511129)
 * I’m no php pro but I think this would do it,
 *     ```
       <?php if (in_category('category-slug')) { ?>
   
       <?php the_post_thumbnail('single-large'); ?>
   
       <?php } ?>
   
       <?php if (in_category('category-slug')) { ?>
   
       <?php the_post_thumbnail('single-large-graphic'); ?>
   
       <?php } ?>
       ```
   
 * just use the whole thing in place of:
 *     ```
       <?php the_post_thumbnail();?>
       ```
   
 * If not this conditional, perhaps one like it would do what you need.
 *  Thread Starter [alanpeto](https://wordpress.org/support/users/alanpeto/)
 * (@alanpeto)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/multiple-php-the_post_thumbnail-sizes/#post-2511132)
 * I love it…worked!! 🙂
 * That actually solved another problem of mine also! The only downside is if someone
   wants to add more categories they would need to update their single.php as well.
   But I’m set in mine, so this works perfect (although I’d be interested if there
   was another way also…I like to keep things automated).
 * Thank you again deepbevel!
 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/multiple-php-the_post_thumbnail-sizes/#post-2511135)
 * let me dwell on it.
 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/multiple-php-the_post_thumbnail-sizes/#post-2511139)
 * You could do a separate post template for each size thumbnail. then your users
   could choose a template from the post editor.
    ?
 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/multiple-php-the_post_thumbnail-sizes/#post-2511149)
 * or, you could put a conditional in single.php, directing all posts to use the
   current post template for one size, and another post template for the other size,
   depending on the tag.?
 * then users could simply add a tag “large” or “small” to their post and get the
   appropriate image size.
 *  Thread Starter [alanpeto](https://wordpress.org/support/users/alanpeto/)
 * (@alanpeto)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/multiple-php-the_post_thumbnail-sizes/#post-2511151)
 * I like the tag option! Have you done this before? I’m horrible at coding myself
   but can tinker around with help 😉
 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/multiple-php-the_post_thumbnail-sizes/#post-2511154)
 * in single.php,
 * before the loop
 *     ```
       <?php if( has_tag('small') ) :
       include 'small-img-template.php';?>
   
       <?php } ?>
   
       <?php if( has_tag('large') ) :
       include 'large-img-template.php';?>
   
       <?php } ?>
       ```
   
 * don’t know if that’s possible or not, or something like it, I probably didn’t
   do it right but I’ll try it soon. or please, be my guest… :}
 *  Thread Starter [alanpeto](https://wordpress.org/support/users/alanpeto/)
 * (@alanpeto)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/multiple-php-the_post_thumbnail-sizes/#post-2511155)
 * I’m going to try this tomorrow and let you know 🙂
 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/multiple-php-the_post_thumbnail-sizes/#post-2511156)
 * but you’ll need to make the custompost templates. You might as well, if it doesn’t
   work this way, there will still be more options with seperate templates.
 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/multiple-php-the_post_thumbnail-sizes/#post-2511162)
 * A custom post template can be as simple as a copy of your current single.php 
   but with a different name, so this at the very top of the page, right before “
   get the header”
 *     ```
       <?php
       /*
       Template Name Posts: Name your template here
       */
       ?>
       ```
   
 * everything will be the same except the thumbnail code.
 * do this in a text editor, then name it and save as “your-custom-post-name.php”
 * then upload it to your theme’s folder.
 * then if you get [this](http://wordpress.org/extend/plugins/custom-post-template/)
   plugin, the optional template is available in the post editor, you can select
   it from a drop down.
 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/multiple-php-the_post_thumbnail-sizes/#post-2511492)
 * This is probably not the most elegant or simplist solutiom but it should work
   to allow you to assign custom post templates based on categories, which are auto-
   assigned by tag.
 * So, if you had a tag for large images “large” it could be automatically assigned
   to a category called “large”. from there, all posts with in the “Large” category
   can be assigned a specific post template.
    [thread, check last post](http://wordpress.org/support/topic/post-template-based-on-category-or-tag?replies=11#post-2572576)
 * It involves putting code in functions.php and default single.php, -still looking
   for an all in one method.

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘Multiple php the_post_thumbnail sizes’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 14 replies
 * 2 participants
 * Last reply from: [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/multiple-php-the_post_thumbnail-sizes/#post-2511492)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
