0

I am designing a magazine style theme and I want different image sizes as to show on index.php page. Now for this, I am using <?php the_post_thumbnail( array(100, 100) );?> but it is picking 150x150 images not 100x100 images. So How to pick my desired different size of images that are uploaded before not after the theme using?

Note: My default media setting in WordPress blog is 150x150, 300x300, 1024x1024 respectively for thumbnail, medium, large.

2

You can use add_image_size() function to create custom sized images. You only need to paste some piece of codes in your functions.php and then update the template files accordingly.

For example :

add_image_size( 'category-thumb', 300 ); // 300 pixels wide (and unlimited height)
add_image_size( 'homepage-thumb', 220, 180, true ); // (cropped)

And you can use below codes to load those images in your template.

the_post_thumbnail( 'category-thumb' ); 
the_post_thumbnail( 'homepage-thumb' ); 

Hope this helps. See this page for more info.

  • Your Code Is Not Re-sizing MY Old Uploaded Images. I Want Then In A New Size Also... – Muhammad Hassan Oct 21 '14 at 14:17
  • Yes, it won't re-size the existing images. But it will work for the new images you're adding. Can you please try this plugin. wordpress.org/plugins/regenerate-thumbnails , may be this will help you to re-size old images too. But please take a backup before doing so. – Hakkim Oct 23 '14 at 4:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.