WordPress – How To Add Post Formats In WordPress To Support Theme



Wordpress Development

Hi Friends, After long time I am back to blogging and now I will write many useful things related to WordPress, php. Today I am going to write something 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 :

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

Now you can use/add this post format in your theme as per your need. So if you want to add post format in your theme then what you should do? Every theme have functions.php open it and add below line anywhere in functions.php file :

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

If you added this line in functions.php then you are done.Now go to add new posts and you can see post formats at right side like this :

Post format Wordpress   How To Add Post Formats In Wordpress To Support Theme

Now you can select any of post format from there for post you are writing. You can add more post formats later when you need them by adding more post formats to the line you added in functions.php.

Now you can see Standard post format also, you were thinking that you didnt add any post format like this also I didnt mention this type of post format before, So where it comes from? When writing or editing a Post, If you have a post which dont 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.

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.

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

  • http://www.mgtdesign.co.uk/ Yena

    The WordPress post formats aren’t extensible by the users.This is a nice content.The written skill is so good.I am very impress to this one.This is an amazing.Thanks to share this blog with us.Keep it up.

  • http://www.seopositiveltd.co.uk/ Michle

    This is a nice content.Theme system is a way to “skin” your weblog.This is well informative.I appreciate to this one.Thanks top share this blog with us.Keep it up.I will keep share in future.

  • http://www.adsyou.com/ شقق للبيع في الاردن

    This is a nice content.The written skill is so good.I am very impress to this one.This is an amazing.

  • http://izmirescortbayan.com/ Izmir escort

    Thank u sir..

  • http://proto-pic.co.uk/ uk electronic components

    Nice post.Very Informative too.
    Thanks for sharing!