Today there are innumerable blogs on any topic you would choose. If you are a blogger your main priority would be to make your blog, stand out! Make it more attractive and tempt people to read what you right.
One of the most important technique that major blogs use is setting a featured image for each post.
This can be achieved very easily as it 's there in-built in wordpress. But you have to enable it in functions.php file within your theme folder.
Here is how you do that:
Paste this within your functions.php file.
Additionally you can specify which should have this feature in an array like this:
You also additional control over this, you explicitly decide the dimension or hard crop the thumbnails etc.
The dimension can be set like this:
Cropping can be achieved by this piece of code:
To get the featured image in your theme just add this in your loop:
For people who want to know more further information on this is available in the following links:
Hope this article served its purpose. For any queries please do use the comment form below.
One of the most important technique that major blogs use is setting a featured image for each post.
This can be achieved very easily as it 's there in-built in wordpress. But you have to enable it in functions.php file within your theme folder.
Here is how you do that:
add_theme_support( 'post-thumbnails' );
Paste this within your functions.php file.
Additionally you can specify which should have this feature in an array like this:
// Add it for posts
add_theme_support( 'post-thumbnails', array( 'post' ) );
// Add it for pages
add_theme_support( 'post-thumbnails', array( 'page' ) );
You also additional control over this, you explicitly decide the dimension or hard crop the thumbnails etc.
The dimension can be set like this:
//the scale is pixels by default
set_post_thumbnail_size( 50, 50 );
Cropping can be achieved by this piece of code:
//the scale is pixels by default
set_post_thumbnail_size( 50, 50, true );
To get the featured image in your theme just add this in your loop:
//setting only the width or height will help you preserve
//design if you have not set to resize the image
<?php if (has_post_thumbnail()) { ?>
<img src="<?php echo $image[0]; ?>" width="238"/>
<?php } ?>
For people who want to know more further information on this is available in the following links:
Hope this article served its purpose. For any queries please do use the comment form below.
Comments
Post a Comment