WordPress 3.0 Part 1—Pre 3.0 and Beyond

This post has three parts. This is part one. Visit the other parts below:


I’m a big fat WordPress fan. I love the people behind it, I love the ethicsand I love how it makes it easy for me to make cool sites that my clients can update themselves.

Not really being much of a PHP developer, I can still get by and can make fairly capable themes from-scratch for my clients. However, it was getting to the point where I couldn’t offer clients an easy way to input content that wasn’t a standard page or a standard blog post without getting a bit hacky with posts, categories and tags.

These solutions were OK, but really far too much of a workaround for clients who were only fairly basic computer users in the first.

Then along came the wondrous…

WordPress 3.0

Actually, it started a bit before that with WordPress 2.9 with the infinitely useful post thumbnails.

Featured Images

But I’ll carry on by calling ‘post thumbnails’ by their new name, ‘featured images’, as this is what they’ve become known as since WordPress 3.0.

Featured images were a selling point in many magazine-style themes for a long time. The ability to have an image that was a visual representation of a post was incredibly sought-after, especially if those images could also be shown in some kind of javascript carousel that rotated the images on the front page of the site. As a result, a huge amount of post-image carousel-type themes exist using all kinds of hacky ways to select a post’s image as the ‘featured’ one.

I used the excellent Get The Image plugin by (the equally excellent) Justin Tadlock when I wanted to use a featured image in a theme. Get The Image cycled through images linked to your post through custom fields, then through the attachments to the post, and even setting a default image, making it really easy to implement featured images in a way that all clients could understand. I still would recommend Get The Image if you want to pick images straight from your posts, rather than setting a specific featured image.

However, setting a specific featured image couldn’t be easier, and I see very few occasions where it wouldn’t be perfect for the job.

First, you’ll need to enable featured images in your functions.php file. This prevents a ‘Featured Image’ box appearing in themes which don’t support the use of featured images (which could cause a lot of confusion for users.) All this requires is a little:

add_theme_support( 'post-thumbnails' );

Then you can see the Featured Image box appear in your post and page editors.

Featured Image box in the WordPress Post editor

Featured Image box in the Post editor

The image selection process is identical to that of adding standard images into the post. You can choose to select from your computer, from a URL or from the Media Library. All you need to make sure is that, instead of hitting the ‘Insert into Post’ button, you select ‘Use as featured image’.

When adding a featured image to a WordPress post, ensure you select 'Use as featured image' when selecting an image

Ensure you select ‘Use as featured image’

If you only want to allow Featured Images for posts in your theme, you can specify this through:

add_theme_support( 'post-thumbnails', array( 'post' ) );

Or for just pages:

add_theme_support( 'post-thumbnails', array( 'page' ) );

Then when it comes to including the Featured Image in your theme, you’ll just need to include:

<?php the_post_thumbnail(); ?>

Really nice and simple!

Even better, you can have more fine-grained control over the sizes of the images, and have different types of image sizes through a few more lines in your functions.php file:

set_post_thumbnail_size( 100, 100, true );
// Set the standard size for your featured images
add_image_size( 'magazine-column-image', 400, 300 );
//Specify a custom image size, you can do this as many
times as you want

This is great if you want to output small thumbnail images on your homepage template and large feature images on your article pages.

For more depth on featured images I recommend you read Mark Jaquith’s pro writeup New in WordPress 2.9: Post Thumbnail images.

Custom Taxonomies

As early as WordPress 2.8 also came custom taxonomies, a sneak peek into something beyond bloggy categories and bloggy tags. For those who blog on specialist subjects you can do without categories and have different hierarchical taxonomies (category trees to people like me), such as ‘genres’ for your film reviews.

If you wanted to tag your film reviews with different actors names, but still keep standard tags to describe your review, you can do this. If you still wanted to organise your fashion blog by different types of articles, using categories, but also wanted to choose from a list of  items of clothes to describe your article, you can do this as well.

These are a bit trickier to implement than post thumbnails. Not much, but there’s a bit more to explain in the functions.php file, so if you want to know more I’d recommend that you visit one (or all) of the fantastic resources that I use, below:

  1. Custom Taxonomies on the WordPress Codex
  2. Custom Taxonomies in WordPress 2.8 by Justin Tadlock
  3. Creating a page template that lists all your custom taxonomies by Justin Tadlock
  4. Introducing WordPress 3 Custom Taxonomies on NetTuts

This post has three parts. This is part one. Visit the other parts below:

2 comments

  1. bookmeister

    @laurakalbag good effort on the wordpress blog posts. You could write a book :-)

    Reply

Leave a Comment

Your email address will not be published. Fields marked with * are required.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>