One of the new features in WordPress 3.1 is the ability to format posts. Most newbies, on the other hand, have no notion what post formats are, why they’re important, or how to use them. After reviewing the alpha version of WordPress 3.1, we’ve decided to explain the what, whys, and how-of to’s the new Post formats feature in WordPress 3.1.
What are Post Formats and Why Should You Use Them?
Post Formats are meta data that themes can use to customize how a post is presented. In layman’s terms, a post format is a way of styling a specific post. You can specify the “format” of a post’s display using this feature. This function increases the number of options available.
This feature improves WordPress’ microblogging capabilities because you can now have videos, links, photographs, audios, quotes, statuses, and more all in one spot, and they’ll all be designed appropriately.
Usage Illustrations
Let’s have a peek at the official Digging into WordPress blog. On the homepage, they have two different types of post styles. One is a full post that displays an extract, similar to any other blog. What’s more fascinating is that they have a specific style of article that consists of external links to other blog entries that they think their readers will find valuable.
Blogging is all about sharing resources, and it’s not uncommon for a blogger to simply link to an external site that they think their readers will find valuable. The biggest issue they have is that they have to create a new post only to direct people to another website. Because the end-user does not know what form of post it is, this causes confusion. The user may have to click on the full view of the post to discover that the author wants them to click on an external link. Despite the fact that there are hacks like this one that allow you to link to external URLs from post titles, this post format issue will solve the problem.
One of the new features in WordPress 3.1 is the ability to format posts. Most newbies, on the other hand, have no notion what post formats are, why they’re important, or how to use them. After reviewing the alpha version of WordPress 3.1, we’ve decided to explain the what, whys, and how-of to’s the new Post formats feature in WordPress 3.1.
What are Post Formats and Why Should You Use Them?
Post Formats are meta data that themes can use to customize how a post is presented. In layman’s terms, a post format is a way of styling a specific post. You can specify the “format” of a post’s display using this feature. This function increases the number of options available.
Why are you interested in using Post Formats?
Post formats eliminate the need for categories to achieve similar styling effects. To achieve this effect until now, developers hacked WordPress categories, which resulted in a lot of clutter and confusion for new bloggers. Not only will using post formats reduce category clutter, but it will also make your blog portable between themes that support those formats.
It will also make your blog more user-friendly for your readers because your user will know exactly what type of post they are viewing. It will also make your blog more lively because you will have a variety of post styles on your blog page. Right now, most blog post display looks very dull because all posts look alike. The post formats will fill a need in WordPress-powered sites that has been sorely lacking.
In WordPress 3.1, how to Add and Use Post Formats
Post formats will be a theme-activated feature, just like post thumbnails, menus, custom backgrounds, and custom headers. This means that you’ll only be able to use this function if your theme is compatible.
To follow this course, you must have a basic understanding of HTML, CSS, and the WordPress loop’s functions.
You must enter your theme’s functions.php file and insert the following code to activate “post formats” in WordPress 3.1:
1
|
add_theme_support( 'post-formats' , array ( 'aside' , 'gallery' ) ); |
Note that aside and gallery are not the only post formats available. The following are the post formats that are available:
- aside – A style that is commonly used without a title. It’s similar to posting a status update on Facebook.
- A transcript of a chat.
- A gallery is a collection of photos.
- A link to another website.
- A single image is referred to as an image.
- A quotation is a phrase that is used to express something.
- status – A brief status update of no more than 140 characters. It’s similar to a status update on Twitter.
- A single video is referred to as a video.
Refer to the WordPress Codex for a complete list of post formats.
You’ll notice a new field in the right hand column of your post write panel where you see publish once you’ve included this code.
You can change the format and publish the post after you’ve finished composing it. This will enable you to present your article in a pre-styled arrangement.
But wait, these pre-styled post types aren’t mentioned anywhere in our theme. So, for the time being, selecting the format in your WordPress post panel will have no effect because your theme does not know how to show it. We’ll need to change our post loop to accomplish this.
The conditional tag has post format will be used in this example ()
1
2
3
4
5
6
7
8
9
|
if ( has_post_format( 'aside' )) { // code to display the aside format post here } else if (has_post_format( 'gallery' )) { // stuff to display the gallery format post here } else if (has_post_format( 'link' )) { // stuff to display the link format post here } else { // code to display the normal format post here } |
What are you still waiting for? Start getting ready for this amazing feature. We can only imagine WordPress being utilized as a microblogging platform in the future, with new themes incorporating this feature.