New WordPress 3.1 features. What's new with the 'Reinhardt' release: post formats, internal linking, admin bar, advanced taxonomy queries, etc.

Exciting New WordPress 3.1 Features

Written by in News |

WordPress 3.1

The long-anticipated release of WordPress 3.1 (“Reinhardt”) dropped yesterday and with it comes some exciting new features. As I begin this post, 3.1 has been downloaded 470,142 times and that number is increasing at quite an impressive rate.

Post Formats

Every update has a feature that leads the pack and post formats is definitely driving the Reinhardt train.

A Post Format is a piece of meta information that can be used by a theme to customize its presentation of a post. … The standardization of this list provides both compatibility between numerous themes and an avenue for external blogging tools to access this feature in a consistent fashion. ~ Post Formats

WordPress 3.1 Post Formats

WordPress 3.1 Post Formats

In other words, post formats make your WordPress site a bit more Tumblr-ish — users can change the look of each post depending on what post format they have chosen. There are 10 supported (and optional) formats:

  1. standard – no format; this is what we’re all used to.
  2. aside – used for posts outside of the normal flow. Stuff like news.
  3. gallery – a gallery of images.
  4. link – usually just a link; possibly a title as well.
  5. image – a single image post; great for photo blogs.
  6. quote – a single quotation.
  7. status – like a Facebook or Twitter update.
  8. video – a single video.
  9. audio – audio file; great for podcasters.
  10. chat – a chat transcript; great for eavesdroppers.

Making Sense of Post Formats

The way WordPress previously worked when you published a post is, well, rather bland. Everything looked the same no matter what type of content you were posting. The way it works now, changes all that. Say you wanted to post a quick pricing update, or better yet, a holiday discount code for one of your services or products but you don’t really want any meta data to show (like author, date, category, etc.) and you want the comments disabled. All you’d have to do is select “Aside” under Format and *magic* it’s done for you (providing that your theme has Post Formats enabled and is styled/displayed accordingly).

How To Add Post Formats to Your Theme

Open your themes functions.php, or if you’re a Thesis user open custom_functions.php and paste the following code:

add_theme_support( 'post-formats', array( 'aside', 'gallery', 'link' ) );

Add as many or as little supported formats as you’d like.

Using Post Formats

Now that you have post formats enabled you’ll see a new meta box in your post editor under the Publish box. However, selecting any of them won’t do much (posts will look the same as they always have) since your theme most likely doesn’t know how to display it. The fun part will be when all your favorite Themes have default styles for the new post formats. Until then we need to do some tweaking of our own:

For example, if we wanted to display a different icon for, say, link post formats (à la Tumblr) we would have to edit The Loop and add the following where we want the image to appear:

<?php if ( has_post_format( 'link' ) ) { ?>
<img src="link-image.png" alt="Link" />
<?php } ?>

An even easier way to style posts depending on post format is by using the post_class() template tag. Most well-coded themes and frameworks already utilize this in the following way:

<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

This function will create CSS selectors such as, format-link, so you can style post formats like so:

.format-link {
	background-image: url(images/link-image.png);
	background-repeat: no-repeat;
	background-position: left top;
	padding-left: 26px;
}

Post Formats vs. Custom Post Types

If you want it to show up in your sites main RSS feed, then it’s probably not a custom post type.

Mark Jaquith

Confused? Me too, the names are all wonky. Custom Post Types are things like pages, testimonials, products, etc.

A Post Format is what I just spent the past 7 or so paragraphs explaining; it’s the formatting of a post depending on what kind of data it is.

Custom Post Type Archives and Better Admin Menu Handling

In WordPress 3.0 when you created a custom post type there was no way to display an archive of that post type unless you manually created a page template. Likewise, when you register a post type with show_ui you get a top-level menu item with no way of specifying some other location. WordPress 3.1 changes all that. We now have archive pages and the ability to customize the handling and location of the menu item. Awesome.

Admin Bar (à la WordPress.com)

WordPress Admin BarIf you’ve ever used the hosted version of WordPress at WordPress.com, this will look familiar. It is a front-end “editor” of sorts (really it’s just a bunch of links to the backend but it has potential).

Internal Linking

WordPress Internal Linking

WordPress Internal Linking

This is fantastic. It’s no secret that internal linking (linking to your own webpages from other pages on the same site) is a big plus where SEO is concerned, and this is going to make that process a whole lot easier.

In fact, maybe too easy; I predict we’ll see a lot more spam-laden blogs with about 50 internal links on a post with only 52 words. I hope I’m wrong.

Anyway, simply create links as you always have using the Visual Editor and you’ll see the new “Or link to existing content” option.

Advanced Taxonomy Queries

The taxonomy parameter tax_query creates a wonderful new way to filter posts. With it we can do stuff like this:

$args = array(
	'tax_query' => array(
		array(
			'taxonomy' => 'category',
			'field' => 'slug',
			'terms' => array('wordpress', 'plugins'),
                        'operator' => 'NOT IN'
		)
	)
);
query_posts( $args );

The above will display all posts that are NOT IN the “wordpress” or “plugins” category.

We can also do this across multiple taxonomies:

$args = array(
	'tax_query' => array(
		'relation' => 'OR',
		array(
			'taxonomy' => 'recipes',
			'field' => 'slug',
			'terms' => array( 'lunch' ),
		),
		array(
			'taxonomy' => 'post_format',
			'field' => 'slug',
			'terms' => array( 'post-format-images' )
		)
	)
)
query_posts( $args );

The above will display all “recipes” posts that are labeled “lunch” OR that have the “images” post format. Very powerful, very cool.

Read more: Otto on WordPress, WordPress Codex.

Super Admin Network Dashboard

If you use WordPress Multisite you will see a new super admin menu that is separate from the menu you’re used to but will allow for easier navigation.

There’s much more under the hood, like better pagination and sortable columns in the admin dashboard using Ajax, a clutter-free writing interface, a refreshed blue admin color scheme, etc., but these are the things that stood out from the rest. Find the full list of WordPress 3.1 features here.

Need help implementing any of these new features? We’ve got you covered.

Enjoy this post? Consider sharing it: