You may encounter situations where you need to automatically display a thumbnail or image of some kind that will link to posts. Here’s an example of this kind of situation: you want to display recent posts from a certain category on your home page, with a thumbnail for each post and maybe the title and an excerpt. Or, I recently had a client that had a box on their homepage for multimedia where they wanted an image to appear that would represent the latest post in the Media category and would link to that post. A link to this site is at the end of this post, so read on.
I found the solution in two amazing WordPress themes: Mimbo and The Morning After. They both use thumbnails on their home page, and they do it by using WordPress’ mysterious Custom Fields feature.
You need to be able to upload images to your server in order to do this. You can do this via FTP, but to make this as easy as possible for clients, I use the Filosofo Old-Style Upload Plugin which creates a link on your nav bar where you select files for uploading. But first you need to configure this plugin and select a folder where all uploads will be saved:
- Upload the plugin and activate it.
- Go to Options > Uploads.
- Enter your destination directory. I think the best is to use your images folder in your theme folder so that any images you upload will be in an easily portable place. So the path could be something like /home/server/public_html/wp-content/themes/themefolder/images. The plugin will suggest a path, and it is usually right.
- Enter the URI of the folder. It’s something like http://www.yoursite.com/wp-content/themes/themefolder/images.
- You might as well up your maximum file size. I make it 500 kb.
- Allowed file extensions: jpg, jpeg, gif, png, pdf – I add PDF and other types of files I think clients may want to upload.
- Minimum level to upload: I leave it at 6 since I have no idea what this means.
- Click Update Options.
That’s done. Now for how to create a post with a thumbnail image.
- Create an image for your post with the right width and height. The size of the image depends only on the design of your site and where it is going to appear.
- Go into the admin of your site. Click on Upload (it’s on the upper nav bar).
- Select the file you are uploading, select No Thanks so it won’t create a thumbnail, give it a description (that’s good for Google) and click Upload File.
- Once it’s uploaded it will show you the entire URL of the image. Note particularly the last part of the link where it says the name of your image, especially if there are any capitals in any part of the name. You will have to enter the exact file name in step 8.
- Go to Create Posts. Enter your post and title as you wish. Make sure to select the category you have selected as the one that will appear with the thumbnails. Now scroll all the way down to the bottom of the screen where it says Custom Fields. Click on the plus button to expand it.
- Enter the word Image (with a capital I) in the Key field.
- In value, enter the exact name of the file you uploaded. For example picture.jpg or image.gif. Click Add Custom Field.
- Save your post.
Now we need the code that will make this thumbnail appear where you want it to appear. Following is the code for having a thumbnail appear with the title underneath it. This code is adapted from the Mimbo theme, but the code in The Morning After is similar:
<?php
// this is where the Features module begins
query_posts('showposts=1&cat=199'); ?> //change the showposts number to the number of posts that you want to appear, and change cat=199 to your category number, which you can find out by going to Manage > Categories
<?php while (have_posts()) : the_post(); ?>
<div class="thumbnails"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="<?php echo get_option('home'); ?>/wp-content/themes/themefolder/images/<?php
// this is where the custom field prints images for each Feature
$values = get_post_custom_values("Image"); echo $values[0]; ?>" alt="" /></a>
<p class="title"><a href="<?php the_permalink() ?>" rel="bookmark">
<?php
// this is where title of the Feature gets printed
the_title(); ?></a></p></div>
<?php endwhile; ?>
Wanna see an example? Check out this site, scroll to the bottom and look at the left-most column that is called Media. That image there is a thumbnail that was uploaded and entered in the Custom Field of the post it links to.
Update Nov. 27, 2007: This post got a lot of comments here, and on Weblog Tools Collection who referred to it. Lots of people gave more recommendations on how to manage thumbnails with custom fields and/or plugins, so I collected these tips into one post which you can see here: Images, thumbnails and custom fields in WordPress.
Pingback: How To: Create a Thumbnail For Each Post and Display On Your Homepage()
Pingback: Weblog Tools Collection » Blog Archive » WordPress Post Thumbnails()
Pingback: Images, thumbnails and custom fields in WordPress | WordPressGarage.com()
Pingback: Changing where WordPress saves your uploaded images and files | WordPressGarage.com()
Pingback: » Incrementando seu wordpress()
Pingback: links for 2007-12-13 | MY Vast Right Wing Conspiracy()
Pingback: Interesting websites for SEO, Web Marketing and everday work from Sante - December 29th()
Pingback: Blogbuster: ?????, blogs, blogging, RSS, Wordpress, ??????????()
Pingback: 25 hacks para dinamizar seu Wordpress! — Bytes a Go-go!()
Pingback: Nearly Everything » links for 2008-01-26()
Pingback: Link notes del 4 2 2008 » Sapientone()
Pingback: 63 Essential Wordpress Hacks, Tutorials, Help Files and Cheats | Speckyboy - Wordpress and Design()
Pingback: 63 essenziali Wordpress Hacks, Tutorials, Help Files e Cheats : technorati.it()
Pingback: Wordpress Tutorials/Hacks « The house of software freeware()
Pingback: links for 2008-03-16()
Pingback: Jazz Up Your Site: 28 Ways To Use WordPress Custom Fields « The Beaver Pond()
Pingback: ?????????????????? - WordPress???()
Pingback: 155 Wordpress Resources, Tutorials, Plugins, Themes, AJAX, Podcasting…WP Monster List | Speckyboy - Wordpress and Design()
Pingback: 155? WordPress ????????????AJAX???…… —— WP ??????? | ???????()
Pingback: Automatic thumbnail image resizing options | WordPressGarage.com()
Pingback: 155? WordPress ????????????AJAX???…… —— WP ???? | Awesomer()
Pingback: How To: Create a Thumbnail For Each Post and Display On Your Homepage | [Blog Tutorials]()
Pingback: 40+ Most Wanted Wordpress Tricks and Hacks()
Pingback: PP BLOG# » Blog Archive » 30???Wordpress??()
Pingback: 9??? » 40+ Most Wanted Wordpress Tricks and Hacks()
Pingback: 9??? » 40+ Most Wanted Wordpress Tricks and Hacks()
Pingback: 40 consejos y trucos Wordpress para dar a tus proyectos aspectos realmente diferentes. « Xyberneticos()
Pingback: Antibioticos « SoLo Se Que No Se NaDa()
Pingback: Cosas por hacer luego de instalar Wordpress | Durmiendo Afuera()
Pingback: IndoProTech.com()
Pingback: ???? » Blog Archive » 30???Wordpress??()
Pingback: 30????WordPress?? | ????--????|????|????|????|WordPress??()
Pingback: 30????Wordpress??????????? | abe design studio()
Pingback: elbandito.us » Blog Archive » Tutoriale si hack-uri pentru wordpress ( lista mare )()
Pingback: 63 correções, tutoriais, arquivos de ajuda e dicas essenciais para Wordpress | Rafael Bernard Araújo()
Pingback: ???????30???Wordpress?? | Idiigo.com()
Pingback: Trucos y consejos para Wordpress | Seosistems()
Pingback: Los 40 trucos mas importantes de Wordpress « Camyna.com()
Pingback: Más de 40 consejos y trucos para Wordpress « El Cubanito Web()
Pingback: WordPress ????40+?????????? - WordPress???()
Pingback: webaktuel » Blog Ar?ivi » Links for 2008-08-04 [del.icio.us]()
Pingback: Wordpress Hacks, Guides and Tricks | TechnoBuzz.net()
Pingback: RCDM » Blog Archive » 40 consejos y trucos para Wordpress (muy interesante)()
Pingback: Redbots » 30????Wordpress??()
Pingback: Morpho Designs » Blog Archive » A History of Brief Time()
Pingback: Wordpress ile ilgili 155 kaynak « YEAH28 - Her ?ey Sizin ?çin()
Pingback: 40 consejos y trucos para Wordpress | ProyectoAurora.com()
Pingback: Best of WordPress Tutorials – More than 100 recourses | Tutorials | .:Lirent.net Hacks:. | All about Web 2.0, SEO, PHP5, Ajax, Adsense, Unix/Linux, Free Stuff, OpenSource, Designs, Wordpress, Hi-Tech etc()
Pingback: 5 Trends of Popular WordPress Blogs- Part1()
Pingback: Wordpress ile ilgili 155 kaynak : ZDaYLaN.CoM()
Pingback: ???? » Blog Archive » 30???Wordpress??()
Pingback: Wordpress ile ilgili 155 kaynak |()
Pingback: 155 Wordpress Resources, Tutorials, Plugins, Themes, AJAX, Podcasting…WP Monster List | Kênh Thông Tin Chuyên Ngh?p()
Pingback: 41 Wordpress Tricks & Hacks | Tips For Web Users()
Pingback: neext : Robert Sample()
Pingback: Enlaces en mi del.icio.us, 4 12 2008 | Vectoralia()
Pingback: How to: Using Thumbnails in your Sidebar “Recent Post” Listing()
Pingback: Wordpress: 40 Trucos y Consejos para | ProyectoAurora.com()
Pingback: Ezrix » Blog Archive » 49 Hot Wordpress Tutorials/Hacks()
Pingback: Wordpress Hacks Guide | CSS Experiments()
Pingback: 155 Wordpress Resources, Tutorials, Plugins, Themes, AJAX, Podcasting | Design tools()
Pingback: 40+ Most Wanted Wordpress Tricks - o2webdev()
Pingback: John Nasta » Blog Archive » Wordpress tips & tutorials()
Pingback: Make your own Wordpress Theme. Anyone can do it, really! | r_shahin : a different life blog()
Pingback: Wordpress Tricks and hacks of my choice | r_shahin : i am web designing()
Pingback: Wordpress ile ilgili 155 kaynak | iLGinciX TEAM()
Pingback: Giving each WordPress post a thumbnail, and display the thumbnail on the home page()
Pingback: 135+ Ultimate Round-Up of Wordpress Tutorials | About Us | instantShift()
Pingback: Wordpress Tricks and Hacks « Online Free Applications Software Tips Tools Wallpapers()
Pingback: 40 most wanted tips and tricks for Wordpress - itsacoolblog.com()
Pingback: Wordpress-Hacks für Profis | EGM Weblog()
Pingback: 40+ Most Wanted Wordpress Tricks and Hacks | Quest For News, A TUTORIAL Base()
Pingback: 40 Most Wanted Wordpress Tricks and Hacks - Online News & Entertainment()
Pingback: 70 Very Useful Wordpress Hacks & Tricks » De Web Times - Sharing Useful Resources.()
Pingback: 30 WordPress Development Tutorials at BLOG GRAPHIC DESIGN()
Pingback: 40+ Wordpress Tricks and Hacks | Mellowish()
Pingback: 40+ Most Wanted Wordpress Tricks and Hacks | Overflowed Media()
Pingback: Jazz Up Your Site: 28 Ways To Use WordPress Custom Fields : Performancing()
Pingback: 30 WordPress Development Tutorials | SEO & Web Design()
Pingback: Top 40+ most wanted wordpress tips and tricks | Tomislav Mihajlovic (Toma) - Toma2U.com()
Pingback: Student’s Home » Blog Archive » 63 Essential Wordpress Hacks, Tutorials, Help Files and Cheats()
Pingback: Places you can learn how to set up cool stuff using Wordpress custom fields | Design strike()
Pingback: Algunos trucos para mejorar tu Wordpress | http://trukos.net()
Pingback: Unlimited New Useful Wordpress Tips,Tricks & Hacks - Themeflash : One Stop For All Your Web Resources()
Pingback: 36 New Wordpress Tips, Tricks, Tutorials & Hacks | TechnoBuzz.net()
Pingback: US Want - Your Blogs, Social Network, Search Engine for Drivers, UserGuide, Vids, Images, Tutorials()
Pingback: 30 WordPress Development Tutorials | Pro Blog Design – Learningism()
Pingback: 40+ Most Wanted Wordpress Tricks and Hacks | My Tech way()
Pingback: 41 Most Wanted Wordpress Tricks and Hacks | eBookTM | Download ebook, Jetaudio skin, Games()
Pingback: Most Wanted 40+ Tips and Hacks For Wordpress | oOrch Blog()
Pingback: 40+ Most Wanted Wordpress Tricks and Hacks « Los temas del Pelado()
Pingback: 40 consejos y trucos para Wordpress « Los temas del Pelado()
Pingback: 40+ Most Wanted Wordpress Tricks and Hacks | 9Tricks.Com - Tips - Tricks - Tutorials()
Pingback: 40+ Most Wanted Wordpress Tricks and Hacks - Wordpress Releases()
Pingback: 30 Amazing Wordpress Hacks, Tricks, Scripts « Desi Garmi: Malayalam Masti…!()
Pingback: Wordpress Hacks | DaveDesign.us()
Pingback: FAQPAL Blog()
Pingback: Mas de 40 Trucos para tu Wordpress | trukos!()
Pingback: 5 Trends of Popular WordPress Blogs | Evanny()
Pingback: 10 Most Common Wordpress Posts | New 2 Wp()
Pingback: Very Useful 65 Wordpress Hacks | Design your way()
Pingback: 50 Ultimate Tutorials To Make You A Power Wordpress User | stylishwebdesigner()
Pingback: 300 Wordpress Tips and Tricks | Ask-Jaime.com()
Pingback: Wordpress Hacks, Guides and Tricks()
Pingback: Tips & Tricks för WordPress –– del 2/4 | Binero blogg()