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. Great write up. I’m pretty excited about a few of the changes in 2.9, especially the post types an oembed support. I really like the direction WP is taking to make it more useful as a CMS. As you noted, so many sites are doing the magazine style that it just makes more sense. And they didn’t break the way people currently use it in the process. Another reason I heart WP.

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

    But could you elaborate with an example. This sounds like a most exciting feature.

    Thanks.

  3. Some really awesome new features. I can’t wait for the image editing functionality, something which is generally a pain when managing site’s which have their own unique image size & cropping requirements.

      1. Yes, I use Photoshop in a similar matter, but it’s really a pain when you have to do just small adjustments. I lose much time while Photoshop is loading, saving, uploading the file again, and so on… to many steps for a few basic operations. I think this is one of the most important features.

        1. True that! Just found out that my flash uploader doesn’t work anymore.. that kinda sucks since I upload multiple files more often than just one. Hope they can fix that too.

      2. I wrote a little image resizing class for a site I’m working on. It was originally using TDO mini forms, which I hacked and used GD to resize the images before the posts were created.

        I’ve since got rid of TDO mini forms altogether, but if you have image size issues, I’d take a look into doing this. I also created a batch process to resize all the existing posted images.

  4. the_post_image() LONG OVERDUE … Post types look very promising as I keep trying convert my market into a wordpress only market one website at a time … oEmbed cleans out a bunch of plugins … Overall this release looks awesome.

  5. Though it is unclear how plugin authors will seek to use [the _commentmeta 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.

    Except, crucially, _termmeta… hoping this gets a look-in at some stage. There has been some chatter about it in Trac.

    http://core.trac.wordpress.org/ticket/5183 (generic meta table)
    http://core.trac.wordpress.org/ticket/2659 (decision to go with _commentmeta)

    (Wonderful review of the upcoming features, very nicely done!)

  6. Great post & thanks for the code snippet previews. Seeing these changes and modifications makes me want to work harder and creating “good themes”. I’m glad to see WP ratcheting up the requirements a bit as well as JSON compatibility. Those sort of changes allow devs a bit more freedom.

    Thanks!
    -Matt

  7. As a user I’m really looking forward to oEmbed, image editing and the bulk plugin updater. While I’ve been lucky in regards to losing content accidentally, I know that some of my writers have nuked some of their content, so they will appreciate the trash.

  8. While I appreciate your coverage I can’t help but notice your gender bias here. What is with the dumb sexist video and the exclusive address to men only at the beginning of your article?

    1. I’ll answer your stupid ass question Patrick.

      The youtube video is showcasing what WordPress will be capable of with oEmbed and I’m sure he chose that video because it is HILARIOUS to watch that dumb woman try and park.

      Second, the address to men only at the beginning is more than likely because that is the official starting quote from the Indianapolis 500 since the 1940s. Feel free to google that quote if your ignorant ass hasn’t heard of it before.

      While I don’t appreciate your posting this comment, I appreciate that you let everyone know that you are a woman with the name Patrick… that must suck to be you man. Do us all a favor and fist yourself instead of posting here again.

      1. Ick! – Mr. Wiz. Uncalled for rudeness and grossness. Perhaps you should refrain from posting. Oh, and I am a 67 year old woman and could care less about the issue Patrick brought up. I do care about respecting other commenters.

  9. Gee thanks for the response. I am just asking. Can’t you see that it might be a little… alienating for some?

  10. Thanks for the write up. This might be too technical for some of us, but the oEmbed and Image Editing would give non-tech savvy people some blast!

  11. Great article and in response to the video…
    1.) I almost peed my pants laughing
    2.) I now feel like a stunt car driver in comparison.

    Awesome!

    ps. I am SO not offended by the statement “Gentlemen, start your engines” because the last time I checked my chauffeur was a male. :P

  12. Great write-up, but frankly I am underwhelmed. Seems like they might be running out of ideas, or that the convoluted code base doesn’t allow for much more. I guess that’s a good thing because at least this upgrade sounds like it isn’t going to break a whole lot. It’s additive.

    Did you have anything on your personal wishlist you would have liked to have seen?

    I would have liked to see more customizability for the visual editor, I just the other day customized quite a bit of it in the core code, and it wasn’t pretty. Changed the editor font, changed the toolbar buttons to sets I actually use, took out the code that hides the para and break tags even in the HTML view (pet peeve of mine, and created a lot more screen real estate for the editor.

    Not something I can recommend to most people, because it’s just scattered all over the code base. Took forever to find most of these settings.

    Also, there are some ideas about how to speed up curation…

  13. If you end up going to WordCamp NYC, I’d highly recommend attending the “Custom Content Types” session. It’ll be about the Pods CMS plugin, and the limitations of using custom post types + postmeta.

  14. I just upgraded to 2.8.6 WordPress version and 2.9 is just aorund the corner. WTF. Anyway can’t wait for it. Looks like it has improved its features a lot

  15. Tell me if I’m wrong, but with the post_image and post_types then this could really work for opening up WordPress as a fully-featured CMS.

    The UI for post types in 3.0 will be a godsend for those scared of confusing less-technically minded clients.

    1. Agree. The day WP works as a fully featured CMS it will be usable in completely different scenarios. As a news-platform its fantastic already, but for a corporate site it`s not that great.

  16. Thanks for the write-up Aaron.

    Regarding the post types — we’ll be able to create a different template for each post type?

  17. Thanks a lot for the article Aaron. Minus Patricks lame comment about you being sexually biased, I found all the info on here to be a great read! Can’t wait for WP2.9 to launch so I can start taking advantage of all these features!

  18. Though it is unclear how plugin authors will seek to use this table

    I can think of *lots* of uses.

    What about adding extra fields to the comments form?

    You currently let users rate your posts — what about attaching the star ratings to their comments instead of just to the post? You store the rating as metadata for the comment, and can display the rating each commentor left.

    What about rating comments themselves? Just like Digg and other social sites, you can “thumbs up” or “thumbs down” a comment. These counts are metadata attached to the comments.

  19. hey Aaron,
    Your post took me two cups of coffee to get through but it was worth it!
    I’ll be upgrading to 2.9 when it come out. I stuck with 2.6 for over a year because upgrading seemed like too much work. I finally got scared into upgrading to 2.8.4 about a month ago or so and I’m glad I did. My friend didn’t, and his blog got hacked last week. As a public service announcement, if you aren’t upgraded to at least 2.8.4, DO IT NOW! :) I’m glad I didn’t learn the hard way.
    Anyway, you didn’t say anything about security in 2.9 (or I missed it) but I’ll be upgrading to it just the same. Thanks again for a great post. scott (aka show booths)
    PS. Now I’m off to go get a third cup of coffee. :)

  20. This was a good read. Perhaps this upgrade will be the one where I finally fix a few small bugs with my blog by exporting all my posts, reinstalling WP 2.9 then importing everything back in (of course, testing all that on another WP instance to make sure it’s going to work).

    Good changes coming, especially in the area of video embedding. No Quicktime embed options?

  21. the_post_image() function is going to be very useful. Currently, users have to jump through a few hoops when adding images to simulate this. Hopefully this will automate some, if not all, of that process. Image editing in WP is also going to be useful for some users who currently use an external app to do simple things like resize images.

  22. Hi Aaron,

    Thanks for the article – Although I am fairly new to WP, it’s great to know it’s being fine-tuned and expanded with new features n a regular basis :-)

    Do you know if the rumoured multi-blog capability (many blogs off one codebase/WP install) in going to be a part of WP2.9?

  23. Regarding “custom post types,” would this be something that you could see making a plugin like More Fields obsolete? I feel like More Fields does what I need it to do with custom fields, but man, a WP integrated interface would be significantly cleaner for sure.

    The image editing will be incredibly useful for a lot of people, of course. Photoshop is way too bulky for much of the really simple image editing blogs use it for, and this would cut back on that significantly.

    1. This is what I’m really interested in – a proper UI for custom content types. I’m about to start a couple of sites for a client using either More Fields, or more likely, Magic Fields, as Flutter seems to be stalled. This article does somewhat tantalising refer to a full UI in WP 3.0 for adding custom content types.

      I love WP and find it great to design for, but find myself routinely using Drupal for client sites (even though it’s a severe pain to design templates for) basically because it’s a true CMS.

      I’d love to focus just on WP, but bending the post OR page paradigm with plugins, custom code etc feels like storing up trouble for later… if custom content types like Drupal CCK was in core, a) you’d know it wouldn’t break with an upgrade, unlike a plugin, and b) the WP-not-a-real-CMS snarks would shut up for a bit.

      Realise adding such things to core really takes WP fundamentally away from it’s roots as blog software, but surely that time has come with an impending 3.0 version. WP.com exists for pure blogging!

  24. PHP 5 is not required yet. That’s coming in WordPress 3.0. But MySQL requirements have been boosted from MySQL 4.0 to MySQL 4.1.2.

    There is no change in the requirements for WP 2.9 — the MySQL 4.1.2 requirement came with WP 2.8. There are also no plans that I am aware of to drop PHP 4 support in WP 3.0. We still have 12% or so of WP installs using it. Of course to get the best experience, we recommend PHP 5.2.

  25. the_post_image is a great idea but it would need some parameters because magazine themes usually have more than one post thumbnail, sometimes the same image but in different sizes.

  26. Thanks for the update on the feature set. I’m especially looking forward to the image editor that will make those small image tweaks so much easier. Could have used the trash feature last night. Glad to know that it will be there soon.

  27. As far as I can see the possibilities of WordPress 2.9 I must say that I don’t see any revolutionary changes comparing it to WordPress 2.8 I think that changes should go deeper and make this completely new product.

  28. Even easier than wrapping embed URLs in a shortcode is just placing the URL on it’s own line in plain text. It’ll be automatically converted into an embed that way too. :)

    The hope is that more and more sites will support oEmbed and you’ll be able to just copy/paste the URL in to any video/image/etc. site and boom, there’s the embed.

  29. I’ve just started a new WordPress site (no, not the one my name links to) and it is the first one where I will be using Pages in addition to Posts. But from what I can tell (and I could be wrong) visitors cannot leave comments on Pages. Hopefully that will be corrected.

Comments are closed.