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.
Here is the list of features in WordPress 3.1. Being a developer I gave priority to features that interest me the most.
- Post Formats
- Advanced Taxonomy Queries
- Advanced Custom Field Queries
- Archive Pages For Custom Post Type
- Redesigned Linking WorkFlow
- Admin Bar
- Streamlined Writing Interface
- Refreshed Blue Admin Color Scheme
- Pagination and Sortable Columns
- 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.
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
}
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 classformat-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;
}
2. 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 );
?>
2. 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.
$args = array( ’meta_key’ => ‘price’, ’meta_value’ => ’22′, ’meta_compare’ => ‘<=’, ’post_type’ => ‘product’ );
query_posts( $args );
?>
4. Archive Pages 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.
5. 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.
6. 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.
7. 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.
8. 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.
P
9. 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.
10. 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 updatebefore 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
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 tobackup before updating.
I specially want to thank WordPress developers and all other folks who are contributing in making WordPress a better CMS.
Related posts:







Recent Comments