Our Blog

We love to share our experience and knowledge with community.

WordPress 3.1: Ultimate Guide to New Features

WordPress 3.1 has been released. It came with many useful features. In this article we go through them step by step and learn how to use them.

List of Features

Here is the list of features in WordPress 3.1. Being a developer I gave priority to features that interest me the most.

  1. Post Formats
  2. Advanced Taxonomy Queries
  3. Advanced Custom Field Queries
  4. Archive Pages For Custom Post Type
  5. Redesigned Linking WorkFlow
  6. Admin Bar
  7. Streamlined Writing Interface
  8. Refreshed Blue Admin Color Scheme
  9. Pagination and Sortable Columns
  10. New Network Admin

1.Post Formats:

WordPress 3.1 provides a way to mark your post with a style format and later on your theme can be customized to present your post differently based on chosen style format.

WordPress 3.1 provides these formats: Aside, gallery, link, image, quote, status, video, audio and chat. New post formats cannot be introduced by theme or plugin.

To use post formats, you need to add their support into your theme. Using add_theme_support in function.php

To save some time we are using twentyten theme that comes with wordpress 3.1. It targets two post formats aside and gallery. Here is the code from twenty ten function.php

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

It will look like this in your WordPress admin side in post editor.

How to Target Post Format in Theme

To customize the structure of mark-up in you theme you can use has_post_format function. Here is the sample code.

if (has_post_format('gallery')) {
   // code to display the gallery post format here
} else {
   // code to display all other formats' post here
}

How to Target Post Format in CSS

Now we will style the post based on its specified format. For this purpose we will use post_class. it outputs a class name equal to fomat-name. For example for gallery format it will output class format-gallery. It also outputs other class names for their details visit post_class.

So, our post warping div will look like this

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

Now we target the fomat-gallery in style.css

.format-gallery {
	background-color: #DDD;
	padding: 10px;
}

Comparison of Standard Post With Gallery Post

Sample Standard Post

Sample Post With ‘gallery’ Post Format

Advanced Taxonomy Queries

WordPress 3.1 provides advanced taxonomy queries.

Now you can perform simple or multiple taxonomy queries.

Here is an example of simple taxonomy query that displays posts tagged with ‘php’ under ‘technology’ custom taxonomy.

<?php
$args = array(
	'tax_query' => array(
		array(
			'taxonomy' => 'technology', // taxonomy
			'field' => 'slug', // taxonomy term by('id' or 'slug')
			'terms' => 'php' // texonomy term
		)
	)
);
query_posts( $args );
?>

Advanced Custom Field Queries

WordPress 3.1 provides Advanced Custom Field Queries.

Here is an example of custom field query that displays list of custom post type ‘product’, where custom field is ‘price’ and it has a value less than or equal to 22.

But there are some exceptions in using advance custom field queries. Learn more a bout it here.

<?php

$args = array(
			  'meta_key' => 'price',
			  'meta_value' => '22',
			  'meta_compare' => '<=',
			  'post_type' => 'product'
			  );

query_posts( $args );

?>

Archive Template For Custom Post Type

WordPress 3.1 provides archive template for custom post type.

As the posts are displayed on archive.php, custom post type will use archive-posttype.php if exists.

Redesigned Linking Workflow

WordPress 3.1 makes it easier to link other posts and pages.

Check out the screen cast about how to use internal linking.

Admin Bar

WordPress 3.1 provides admin bar for quick link to various useful admin side pages.

By default it displays on site and not in dashboard. But, setting can be changed from user profile.

Checkout the screen cast about admin bar.

Streamlined Writing Interface

WordPress 3.1 by default comes with a clean post editing interface that only provides really important boxes.

User can always change the interface by clicking screen options in top right corner.

Checkout the screen cast about customizing writing interface.

Refreshed Blue Admin Color Scheme

A refreshed color scheme for admin side. That helps you focus more on your contents.

Checkout the screen cast about how to apply new color scheme.

Pagination and Sortable Columns

WordPress 3.1 provides ajax based pagination and sortable columns that help you navigate through tons of contents efficiently.

Checkout the screen cast about pagination and sortable columns.

New Network Admin

WordPress 3.1 moves the super admin menu and related pages out of the regular admin and into the new network admin screen.

This is a major change, if you are running a network of sites. It is recommended to test the update before you apply it on your live site as might be the plugins you are using can create problems after the update.

Read More About Network Admin

Conclusion

Overall WordPress 3.1 makes the life easier for developers and users by providing above listed features. There are also many under the hood changes that make it more robust. So, if you are running a WordPress based site than update to WordPress 3.1 for better experience. Do not forget to backup before updating.

I specially want to thanks WordPress developers and all other folks who are contributing in making WordPress a better CMS.

Comments (9)

  1. Great run down. I can see this being very useful when you want to go beyond the usual blog. For example I have a client who uses products as posts. This would have been great when I was initially setting it up.

    • You are right, I also did a project few weeks back, in which these advance queries would have really helped me. But, at that time it took great amount of time to solve that problem with an alternative/old approach. Thanks..

  2. Hi. You explained it perfectly. I have been trying to understand all this new features in WP3.1 and I haven’t got a clue until I read your article.

    Looking forward to more of your work.

    Thanks.

    Jake

Comments are closed.