Adding post thumbnails in wordpress
Adding post thumbnails in wordpress
Adding post thumbnails in wordpress
In this article I will tell you how to add post thumbnails in your wordpress theme, and in the other part of the tutorial I will show you how to use them.
To add the support for posting custom thumbnails firstly you need to open your functions.php file. In here you have to add the following code:
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 80, 80, true );
The first line will enable post and pages thumbnail support for the theme. This is the most important line, as without it the thumbnails wouldn't work. The second line is optional, it tells the theme what size will the thumbnail be, in this case 80pixels (width) by 80pixels (height).
Now we finished telling wordpress that we want our thumbnails to be enabled, but we didn't tell it where we want them. So to do this we need to open the page where our posts or pages are situated. This may vary from theme to theme. Most oftenly it will be directly in the index.php file. Next step is finding "the loop":
More about the loop here
Now I will show you two options. One option is to simply add the thumbnail code inside the loop. And in result when wordpress will find that the author has added his thumbnail it will display it, and when the thumbnail isn't added, it won't do anything. So here is the code, wchich you must add between the loop:
Now for the second option, if you want to display a default image when the author didn't add any thumbnail of his own, you must apply this code:
What Lessons Are There in Shane Warne's Twitter Rant about Brittish Airways? How To Achieve Best Wordpress Seo WordPress plugin : Gravity Forms Review WordPress Hosting with ByteBob Fourneau Bruleur De Graisse Forum Advantages of using WordPress eCommerce Bluehost Wordpress Install The Second China Blow Molding Rotational International Forum Cum In April, Held In Shanghai - Bluehost Wordpress Mu Bluehost Wordpress Review Fett Verbrennungs Ofen Forum-Fett Verbrennungs Ofen Bluehost Wordpress Upload Limit Simple Wordpress Shortcode Tutorial
www.yloan.com
guest:
register
|
login
|
search
IP(216.73.216.125) California / Anaheim
Processed in 0.016421 second(s), 7 queries
,
Gzip enabled
, discuz 5.5 through PHP 8.3.9 ,
debug code: 19 , 1633, 231,