How to Add Post Thumbnails

In previous versions of WordPress (prior to 2.9 if I remember right) there wasn’t in-built possibility to use post thumbnails. That’s why some themes (the best of them) used custom fields to hold a related image URI. Some of themes retrieved the first image from posts. Each theme had its own method to store/get the image and that’s why changing a theme was a quite time-taking process.

It seems now that was ages ago. Currently the most of the WordPress themes support in-built WordPress functionality of post thumbnails. But probably it’s not obvious how to set them because I receive questions of them every day.

Firstly,

What are the post thumbnails?

A post thumbnail is a small picture that displays near the post excerpt on pages like index page, category and other pages where a list of post appears.

How to set a thumbnail for a Post?

Generally there are 4 steps to do this:

  1. Create a post
  2. Upload an image to your blog
  3. Set the image as featured image
  4. Save the post

Create the post

Ok, it looks obvious and I will not describe the step :) Just note that you can use any of your old posts for that.

Upload an image to your blog

Now when you are on the add/edit post page there is the link “Set featured image” in the right sidebar. Just click the link:

You’ll be taken to the “Set featured image” window:

As you see the window is exactly the same as any other “Add Media” window. So you can upload an image there. Or you can use any of previously uploaded images from Media Library.

Set the image as featured image

After you’ve uploaded an image, click “Show”. At the very bottom of the image properties you’ll see the the link “Use as featured image”. Click it:

After you click the “Use as featured image” link, you’ll see that the featured image is set for the post:

Save the post

Nothing new here. Just save the post.

That’s all. The post thumbnail is set!

Codestyling localization plugin fix

The Codestyling localization is the great plugin that helps theme and plugin translators greatly. This is really the best plugin ever for translators.

Unfortunately it has one very annoying bug on my web-server configuration – it cannot deal with quotas and “\n” sequence. The plugin adds additional slashes before the symbols.

I don’t know if this is something specific on my web-server or it happens everywhere (I tested two different servers), but it shouldn’t happen anyway. I’ve written to the author but will he fix it? Anyway I fixed the bugs. Read how to fix Codestyling localization plugin bugs

The best way to create dynamic CSS for your WP theme

When you design your own WordPress theme you probably use an option page with options that affect your theme appearance. If so, you need to create dynamic css for the theme and insert it into pages. There are several ways to do that but only one is the best. Firstly let’s enumerate them:

  1. Insert entire css into <style> tag using wp_head call
  2. Write dynamic CSS to a file, link to the file in the head.
  3. Using template_redirect hook to create CSS output based on a special GET variable.
  4. Style.php, which is linked to from the head, and outputs dynamic css.

They are listed in that order because they go from “best” to “worst”.
Some time ago I thought that the best way is the 3rd one but Otto (WordPress support forum moderator) has recently explained why is this order right. Read the explanation