• Jun
  • 04
  • 2012

Today I am going to write about post formats in WordPress. First what is post format? Post format is piece of meta information that can be used by a theme to customize its presentation of a post. WordPress support 9 type of post formats:

Why post formats are important and how to add it in theme?

By using post formats you can make your theme attractive like you can use a small different icon for every different post, you can use different color for post for different post formats..there are many way to use post formats for theme to make theme attractive.

  • aside
  • gallery
  • link
  • image
  • quote
  • status
  • video
  • audio
  • chat

Now you can use/add this post format in your theme. So if you want to add post format in your theme then what you should do? Open functions.php and add below line anywhere in functions.php file :

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

Now go to add new posts/edit posts and you will be able to see post formats at right side.

Now you can see Standard post format also, you were thinking that you didn’t add any post format like this also I didn’t mention this type of post format before, So where it comes from? When writing or editing a Post, If you have a post which don’t require any post format then Standard is used to designate as no Post Format. Also if a format is specified that is invalid then standard (no format) will be used.

Now you added post format now you are thinking how we can get that post format for posts while showing posts on site? Ok, So here is the function to get post format for every post.

<?php $which_format = get_post_format( $post_id ); ?>

You can use this line of code to get post format. If you are using this function in while loop then no need of mention $post_id, it will automatically take $post_id if it is used in loop. If you are using outside of loop, then you must have use/pass $post_id to this function in order to achieve post format for that post.

I hope this article helps you.If you really like this article tweet about it or share it on Facebook or make comment.

Ravi Makhija

Ravi Makhija

A writer, an Entrepreneur. Curious about the internet of everything. Interested in the cutting edge landscape of mobile apps and SAAS products. Blogs for Guru Technolabs - A Mobile App Development Company.

Popular Blogs

Among the many digital tools that are being used with increasing frequency, the one that has the greatest...

Having a Best Website like opening a door and inviting…

In this internet era, the business website is the most…

The Live chat is the common thing now days, if…

Let's Discuss a Project

Please share your unique idea or project requirement with us, our business concern person will get back to you with further details.