WordPress 2.7 is approaching us and there are some new functions for theme developers. I’m so excited, are you excited? I just can’t hide it.

Easy Post Classes

Something I really didn’t expect was the post_class() function. This makes the almost obligatory class=”post” a thing of the past, and replaces it with something infinitely more useful. Straight from the codex:

This includes several different classes of value: post, hentry (for hAtom microformat pages), category-X (where X is the slug of every category the post is in), and tag-X (similar, but with tags). It also adds “sticky” for posts marked as sticky posts.

This is great for keyword stuff…err…I mean SEO. Also it will make styling posts simple and straightforward. This is some functionality that isn’t new to some themes, but now that its part of the core, it is oh so much easier and cleaner.

How to use it

This one is simple enough, stick it inside the loop where you would normally have a class=”post” like so:

<div <?php post_class(); ?>>

Say you want to add a special class, so your posts with a certain custom field are displayed differently than a post without the custom field. Easy enough, you can pass along a single class name, space separated list, or an array of classes:

<div <?php post_class('special_class'); ?>>
<div <?php post_class('special_class class2 class3 class4'); ?>>
<div <?php post_class($my_array); ?>>

Great! But I want to use it outside of the loop, to display something in my sidebar on single post pages cause I’m cool like that. WordPress has got you covered there too, you can pass a post ID as a second parameter:

<div <?php post_class('', $post_id); ?>>

I got a feeling this is going to open up some very cool things when people start to play with it.

A Logout Link

OK so I think this one is relatively boring compared to the rest, but I know this will actually be useful in certain applications. It is the almighty wp_logout_url() function. It does just what you think it does, provides a protected log out link for your users. Use is simple just put <?php wp_logout_url(); ?> where you want it.

Page Menus

Another new function is actually a wrapper for wp_list_pages(). The wp_page_menu() can be used pretty much the same as wp_list_pages(), but one useful little add is the ability to a link to the homepage:

<?php wp_page_menu('show_home=1'); ?>

HTTP API

There’s also a new http api for plugins that looks like it could be useful. From the codex:

The HTTP API is an attempt to standardize the HTTP requests and responses for WordPress. It will eventually obsolete Snoopy and deprecate the other functions in WordPress. That is, once the HTTP API is completely stable.

I haven’t got a chance to really look into any of these, but you should be aware of them as they could be a huge part of whatever plug-in you are writing.

Comment Enhancements

I’ve saved the best for last. WordPress 2.7 has brought some much wanted comment love, threaded, paged, etc. Themes do have support all this although, which will make some of very busy. Instead of repeating all the info about the comment updates, just head over to the WordPress 2.7 Comments Enhancements post from Otto.

More…

That is all I got right now, but there are more new features you may be of interest to you in WordPress 2.7. For a complete look at the features list check out the codex page on WordPress 2.7.