Reputation: 63
I am pretty new to Wordpress
. I want to know how to define image width and height size
for the featured image
? I want all my images should be 100 X 100 px
. So how to do that? Any help and suggestions are welcome.
Upvotes: 0
Views: 3145
Reputation: 13323
Use something like this in your function.php file
<?php add_image_size( $name, $width, $height, $crop ); ?>
Where Parameters will be like
$name
(string) (required) The new image size name.
$width
(int) (optional) The post thumbnail width in pixels.
$height
(int) (optional) The post thumbnail height in pixels.
$crop
(boolean) (optional) Crop the image or not. False - Soft proportional crop mode ; True - Hard crop mode.
For more information just go through the wordpress codex documentation.
Upvotes: 0
Reputation: 2493
put this line in add_image_size('thumb',100,100,TRUE);
functions.php
and call it wherever you want the_post_thumbnail('thumb');
For more information check that link : http://codex.wordpress.org/Function_Reference/add_image_size
Upvotes: 0
Reputation: 5235
After you set the new post thumbnail size, you have to rebuild the thumbnails, because Wordpress has already built them.
For that you can use for example this plugin, but have in mind that it is known for having security issues. My advice is to install it, regenerate your thumbnails so they have the new size you have set, and then uninstall it.
Hope this helps. Cheers.
Upvotes: 1
Reputation: 126
Use this code and adjust your featured image size
<?php query_posts('cat=ID'.'&showposts=NO. OF POST') ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<!-- Thumbnail part start-->
<div style="100px"; width="100px";><?php the_post_thumbnail(); ?></div>
<!-- Thumbnail part End-->
<p><?php echo substr(get_the_excerpt(), 0,65).' [...]'; ?></p>
<a href="<?php the_permalink(); ?>">Read More...</a>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
<?php endif;?>
Upvotes: 1