0

I'm new to learning WP theme development so I may not have worded the title perfectly but that's the best way I could think to explain it.

My theme is on a localhost so I can't link to it but here is a screenshot: https://i.stack.imgur.com/TjJ2j.png

What I want is for the_post_thumbnail to always fill the specified thumbnail media settings.

Currently the thumbnails will be different sizes depending on the width / height ratio.

I have gone into WP Dashboard and set the media thumbnail size for medium at 250px wide by 150px tall. I want the image to always fill that space, don't care if it's cut off but I want it to be that size.

Thanks, I hope I explained it correctly.

1 Answer 1

0

the_post_thumbnail allows for size specificiations. So you would do:

<?php the_post_thumbnail('medium'); ?>

if you changed the image dimensions in the admin, you will need to go back and re-upload the images so they crop to the correct size that you set up

If the issue is the dimensions of the image you are probably looking for a hard-crop. The best bet is to set up a new image size with add_image_size in your functions.php.

add_image_size( 'new-image-name', 250, 150, true );

then re-uploading images then

<?php the_post_thumbnail('new-image-name'); ?>
2
  • Just tried doing that however no change, also tried regenerating thumbnails with no change. The featured image I set in the edit post page is what is used for the thumbnail in this case correct? And yeah that is the code I am using to display the thumbnails.
    – npav42
    Oct 24, 2014 at 15:17
  • check revised answer
    – ScottG
    Oct 24, 2014 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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