In my index.php file, I’m trying to create a thumbnail for each post with the size width: 200px and height 142px.
And on the single.php, I would ike for the featured image to be width: 598px and height: 300px;
for the index.php i tried <?php the_post_thumbnail( array (200,150) );?>
but I cant get it to work.
Is this something timthumb would be used for? or would it not be needed?
For this situation, you should use
add_image_size
. You can find more info about it in the codex. Whatadd_image_size
does is register new sizes for your thumbnails, so you can use them withthe_post_thumbnail
(and other functions). Here´s the example from the codex:You must enter this code in your functions.php file. What this does is register a new size called “category-thumb” with 300pixels in width and unlimited height. You can then call the new registered image size using something like:
If after doing this you notice that your thumbnails are still the same size, that’s probably because WordPress already created the thumbnails for that picture, so you need to create new ones. I recommend using the Regenerate Thumbnails Plugin for this purpose. However, I read that this plugin has some security issues (can’t confirm if it’s true), so what I usually do is activate the plugin to regenerate my thumbnails, and unistall it after I used it. Hope this helps.