wordpress

10 Things You Need to Know About WordPress 2.9

Gentlemen, start your engines! WordPress 2.9 is just around the corner. Unlike WordPress 2.8, which Mark Jaquith describes as the Snow Leopard of WordPress since most of the basis of the WordPress 2.8 upgrade was complete rewrites and optimization of the infrastructure that ran WordPress instead of providing lots of new features in the same way Apple’s new OS X release is a focus on improved performance instead of features, WordPress 2.9 brings major new “bling” to the table. As a reminder of WordPress 2.8, you can see the writeup that Jonathan Dingman brought us last time around.

By and large, this release is a plugin developers release with lots of new APIs and abstraction. However, there are significant additions for theme designers and users as well. As a result, unlike previous iterations of this article (I do one for every major WordPress release), I’m going to break this down into sections for each kind of feature.

Themes: the_post_thumbnail()

Theme developers have a new piece of functionality that have become extremely popular in themes these days. As blogs have evolved from journal form into entities that can be very magazine-like, the use of thumbnail images has also grown. Typically, this layout is achieved through the use of custom fields that must be manually created and populated. No more!

As of WordPress 2.9, if you use the built in image uploader, then WordPress handle this for you. Theme designers that wish to support this feature can add the template tag the_post_image() to their themes to achieve proper placement as required by the theme layout. The template tag can optionally take a “size”, which is one of the WordPress default sizes: thumbnail, medium, large, etc. If none is provided, it defaults to your preset thumbnail size.

Example:

1
2
3
4
5
  <div class="entry">
    <h1>&lt;a href=&quot;"&gt;</a></h1>
   
   
</div>

Conveniently, if a theme is enabled for post thumbnails, the only “feature” currently offering this support in WordPress, then a new “meta box” will be displayed on the Write screen allowing you to assign a post image.

Themes: Register Support for WordPress Features

Editorial Note: Since this article was published, the code has changed to refer to post-thumbnails, not post-images. As a result, function names have also change. The code and examples included before reflect this change. Sorry for the confusion and sorry specifically to theme devs who have implemented the_post_image() feature already. Just change it to the_post_thumbnail()

This may seem to be an obscure feature, and typically, it’s pretty simple to figure out what I’m talking about just by looking at the header. In this case, it’s a bit more obscure because it suggests a feature that is introduced in WordPress 2.9 and then only for a very niche purpose. I can see this being built out over time, and plugin authors can supply their own use cases.

The concept is simple. If a feature exists “” in the core, the only use case is for the thumbnails I described earlier and it is called ‘post-thumbnails’ “” then a theme can declare support for the feature using the add_theme_support() function in the theme functions.php. It can only be declared in this file and it requires a feature be assigned a name. As I mentioned, with WordPress 2.9, there is only one feature that is named and that is post-image. Plugin authors can provide their own new functionality using the require_if_theme_supports() function.

1
require_if_theme_supports('my-custom-feature','/path/to/custom-lfeature-library.php');

Themes would then enable support for the feature by including the following in their functions.php file.

1
2
if ( function_exists( 'add_theme_support' ) )
add_theme_support( 'my-custom-feature' );

We’ve used the function_exists() check on the add_theme_support() function to ensure backwards compatibility with WordPress installations prior to WordPress 2.9. Similarly (and possibly confusingly in this context), before you would have to check for the existence of a plugin by using a function_exists() or class_exists() piece of logic and loading it if the class or function did exist, but now there are on/off switches to get it done.

Users: The Trash Can

On Windows, they call it the Recycle Bin. On Macs, it’s the Trash. In both cases, the feature exists to help people recover from accidental deletions. We have all had those moments where we nuked something we had no intention of nuking. With WordPress, accidental deletions have been permanent. In WordPress 2.9, everything is recoverable now with a new Trash feature. When you delete a post, page, category, comment, or any bit of content, it is moved to the Trash where you can decide whether to pull it back at a later date.

The Trash Can view. From here, content can be restored or deleted permanently.
The Trash Can view. From here, content can be restored or deleted permanently.

Trash collection is done every 30 days by default, but it is possible to change this by editing your wp-config.php file. Add the following to your config file to change trash collection to every 7 days. Modify as needed.

1
define('EMPTY_TRASH_DAYS',7);

Users: Image Editing

One of the hot new features in WordPress 2.9 is image editing. Now don’t get me wrong. This isn’t Photoshop. And it only support basic functionality at this time. However, image editing will allow bloggers to crop, scale and rotate images from right within WordPress. From the media library, you can edit images by clicking the Edit link under an image, and then clicking the Edit button on the individual image page. This brings up an interface like what is shown below.

The WordPress 2.9 Image Editing Screen
The WordPress 2.9 Image Editing Screen

Users: oEmbed

oEmbed, as described at oEmbed.com, is a specification that allows media providers like Flickr, YouTube and others to provide data for consumer applications like WordPress about media. So by including an Embed (Use the File uploader and choose “From URL” and paste the link to the page that contains the media, not the media file itself) in a post or page, WordPress can retrieve the relevant specs on the media file and formulate a properly formatted embed accordingly.

Below is an embed of one of my Flickr photos using oEmbed.
Scenes from San Francisco

Below, is an oEmbedded YouTube video (Original video removed so here’s the Iron Man 2 Trailer).

If you don’t want to use the GUI for this stuff, you can simply wrap the URL to the media page in embed shortcode tags like this.

1
[embed]http://www.youtube.com/watch?v=ZGp220EQUis&amp;feature=popt00us0a[/embed]

The list of supported oEmbed sites in WordPress are as follows:

  • YouTube (via oEmbed)
  • Blip.tv (via oEmbed)
  • Flickr images and videos (via oEmbed)
  • Hulu (via oEmbed)
  • Viddler (via oEmbed)
  • Qik.com (via oEmbed) “” never heard of this site, but it was listed on oEmbed’s website, so”¦
  • Revision3 (via oEmbed)
  • Google Video (via an internal handler)
  • PollDaddy (via an internal handler)
  • DailyMotion (via an internal handler)

That said, plugin authors can add new providers if they want by using the oembed_providers filter or override altogether with the WP_oEmbed->providers property.

Plugins: Custom Post Types

One of the strengths of Drupal has been its ability to have multiple types of contents contained in objects that all look alike to PHP. WordPress has supported a variety of content types as well, but it has not been nearly as flexible making WordPress a blog platform with some additional support for pages and attachments. Technically, the only post_types that WordPress has supported have been post, page, revision and attachment. While it has technically been possible to add new post_types (like podcast, mp4, or tutorials – they could be anything, really), it has been a chore and required plugin developers to handle quite a few moving parts in order to make it all work properly.

No longer. Plugin authors now have API to register new post types, opening up the possibility for even more creativity and uses for WordPress.

get_post_type()

The get_post_type() function can only be used in the Loop. It returns the type of post a post is. Keep in mind, I’m using post loosely. All content in WordPress is kept in the posts table thereby inheriting the name “post”, but post is also a kind of content that is associated with blog content (as opposed to page which is a pseudo-static page, attachment which is information about an image or file uploaded with the media uploader, etc).

get_post_types()

The get_post_types() function will return a list of all types of post content. By default, this will be post, page, attachment and revision. Refer to the source code for optional arguments that can be used to control what kind of data is returned.

register_post_type()

As a plugin author, you can use this function to create a new post type. The first argument is the unique handle you want to assign to the post type – let’s call it podcast – and the second argument is an array that contains additional elements. The key one here is an exclude_from_search, which by default is set to true. You actually probably want to set this to false unless you really don’t want this additional content searchable. See below for example usage.

1
2
3
4
5
function wpb_podcast_init()
{
register_post_type('podcast',array('exclude_from_search' =&gt; false) );
}
add_action('init','wpb_podcast_init');

There is currently no user interface for post types. There is a patch in for UI that will likely be included in WordPress 3.0.

Plugins: Comment Meta

There has been a variety of meta tables in WordPress. Meta tables, like usermeta or postmeta, are database tables that contain information about the type of data that is stored in WordPress. It allows plugins and WordPress to assign metadata, such as user roles and capabilities, to pieces of data thus extending that data. Now, there is a comment meta table as well.

Though it is unclear how plugin authors will seek to use this table, the fact that it is available is a major deal as it essentially provides meta tables for every piece of content in WordPress now.

Plugins: Metadata API

With the addition of a comments meta table, it has become effectively redundant to duplicate functions throughout WordPress. You have a get_post_meta() function that does the same thing as a get_usermeta() function except they query data from different tables that also look identical except for the data stored in them.

In WordPress 2.9, there is an entirely new Metadata API that can be used to retrieve data from any of these meta tables.

The add_metadata() function takes a meta type (‘comment’, ‘post’, ‘user’, etc), the ID of the content type, the key and value of the metadata and whether the information should be unique or not (true or false).

1
add_metadata('comment', 12345, 'twitter_id', 'someyoungpunk');

You can also use update_metadata(), delete_metadata(), get_metadata() and update_meta_cache() for further wrangling. Refer to wp-includes/meta.php for full documentation.

Themes/Plugins: Theme System Modification

A lot of messiness has been eliminated in WordPress 2.9 theming. For one, new template opportunities exist. Now, instead of looking for a template file called category-x.php, tag-x.php or page-x.php, where x is the ID of one of those types of content types, it will look for these templates second. The first template that is now looked for is based on the slug. So if you have a category, tag or page called foo, the first template to be sought after would be category-foo.php, tag-foo.php, or page-foo.php. If none of these templates exist, then the ID-based template file is looked for.

Additionally, plugin developers can register new directories for themes to be located with the register_theme_directory() function.

System: Database Repair Script

The database occasionally needs a good spring cleaning. Other times, the database needs a repair. WordPress ships with a new script that will do just this. It is housed at /wp-admin/maint/repair.php but in order to use it, you need to create a new (or modify if it already exists for some reason) constant in wp-config.php.

1
define('WP_ALLOW_REPAIR',true);

System: Minimum Requirements

PHP 5 is not required yet. That’s coming in WordPress 3.0 will be increasingly implemented over time. But MySQL requirements have been boosted from MySQL 4.0 to MySQL 4.1.2.

Bonus coverage

Other interesting things in WordPress 2.9.

  • JSON compatibility, before only beneficial to PHP 5.2, has been backported for use in WordPress
  • New ‘Undo’ button when using the Visual Text Editor
  • A new sanitization API (with functions like esc_html())
  • The emoticon system can be altered using the smilies_src hook. :-)
  • Bulk Upgrading of plugins
  • Filesystem optimizations pertaining to FTP/SSH etc.
  • rel=”canonical” for single posts and pages aiding in SEO
  • Minify Admin CSS making for quicker (and smaller) page loads
  • Bunny Tags and Jeromes Keywords Importers removed

Published by

Aaron Brazell

Aaron Brazell is a Baltimore, MD-based WordPress developer, a co-founder at WP Engine, WordPress core contributor and author. He wrote the book WordPress Bible and has been publishing on the web since 2000. You can follow him on Twitter, on his personal blog and view his photography at The Aperture Filter.

108 thoughts on “10 Things You Need to Know About WordPress 2.9”

  1. Good article, thanks for the info. Just an FYI to the author – The YouTube video oEmbed that you were demonstrating with has actually been deleted from YouTube. So instead of demonstrating the oEmbed of the youtube video, it is just a hyperlink that goes to a youtube error page. Just thought you might want someone to tell you.

  2. After uploading the first thing I noticed was the disapearance of my TweetMeMe button.
    Deactivated every plugin and still no go.
    Looked for an up to date version (tweetmeme) and have the current version.
    Ended up going back to 2.8.6 for now.
    :(

  3. this release of wordpress really features lots of improvement, i like image editing feature specially. i read in comment of website that it has slight incompability with old theme is it true

  4. Thanks you for the Info, It will certainly help wordpress theme developers like us.

    I have just updated my blog with wordpress 2.9 and excited to play around with the new features.

  5. Great overview, but I just upgraded one of my blogs and I can no longer login.

    It only brings up the wordpress “Update Database” button screen, then it does that and then the next screen is full of error messages and the continue button brings me right back to the “Update Database” screen. It’s looped.

  6. I had couple problems installing this version mainly as related to other plugins. Trying to sort issues out and will report asap. Just make sure you backup all before install, always recommended.

    Thanks for the 10 tips though, couple nice additions indeed.

  7. This looks a really worthy update indeed. I would love to see even better flickr integration but I guess that’s a job for the plugin makers. It does make me wonder what is going to be in 3.0.

  8. Thanks for the write-up! I’ve been digging through articles to get a comprehensive list of all the new features…but yours is the best so far. Good descriptions and examples.

    Cheers!

  9. Thanks for a vwery clear and concise write up. The basic image edition tools, and trash will definitely make this a worthwhile upgrade.

    Also looking forward to some interesting plugins!

  10. This was way more helpful than the WordPress Blog’s announcement of 2.9 was, especially the part about how to do the embeds. I’m going to link to your post from my blog. Thanks.

  11. I just wanted to point out that I tried your method of adding a video using the method you described above it didn’t work.

    (Use the File uploader and choose “From URL” and paste the link to the page that contains the media, not the media file itself) in a post or page)

    According to http://codex.wordpress.org/Embeds you simply copy and past the URL right into the post, not using the file uploader. I followed the wordpress instructions and it worked. Not sure if I just had a glitch but I thought I would point this out.

  12. How is the page slug better than the page template? Now users need to remember the name of the slug to use rather than select from a dropdown, no?

  13. Very good piece. I was looking for someone to come out with such comprehensive coverage. Last question is whether any OS–Leopard or Snow Leopard, specifically–is having any difficulties after the upgrade to WP 2.9?

    Thank you for a job well done.

  14. It would be desirable for optimisation of kernel WordPress, reduction of consumption of resources. All basic new functions in WordPress 2.9 are directed for work with images. Yes it became more convenient to work, however kernel WordPress was not updated about 5 years. Persistently we keep for old, to the detriment of development so we lag behind others CMS. Integration of plug-ins into a system kernel, not a way out.

  15. Great feature-by-feature description. Finally an Undo button — every bodies favorite Microsoft feature. Why did it take so long for basic logic to set in? And a quick picture editor — looks like the beginning of a time savor. This is going to be FUN.

  16. To be clear, to display the thumbnail images in a theme, you need to specify this in functions.php:
    add_theme_support( ‘post-thumbnails’ );

    And then specify this where you want the thumbnail to appear (usually in index.php):
    the_post_thumbnail();

    You will also want to style the image in your .css stylesheet.

    One thing that is a big dissapointment with this, though, is that you still have to manually specify a thumbnail for each individual post. I wish that it would parse the content for images and make a thumbnail out of the first one that it finds.

  17. Thanks for this info on the wordpress update.

    Looks like I will have to go through and upgrade all my sites =P. They should add in a bulk upgraded to upgrade across multiple sites at once in wordpress 3.0

  18. WISH I would have read your post before I tried to upgrade to 2.9. I’ve been using WP for years but with the 2.9 upgrade, it wiped out my entire blog—-and my back-up files are not uploading—so I guess all my posts from 2005 until last week are GONE. *Sigh* Just shows I need to read you more often.

  19. A WP upgrade would not wipe out your blog. I bet if you looked at your database all the posts are still there. You just have some little glitch to fix — a missing wp-config file or missed a file when upgrading or something simple like that.

Comments are closed.