Thursday 14 November 2013

Add Post Formats To WordPress Theme

Important: All scripts hosted on widcraft.googlecode.com don't work anymore because Google has blocked that SVN repository.
It's school holiday for five days in a row, so as a part of the second day of this holiday, I was doing some random stuff around the internet, such as listing to new songs, reading about upcoming Next-Gen gaming consoles, browsing troll memes, blaming Justin Bieber, and more.

So in this busy day I took some time to edit my WordPress website for new feature. I did some thing new (at least for me) with some post formats, and I'm going to share it here on BWidgets. So as a part of that tutorial, here's the basic thing to learn before I post that article, which is adding post format support to your WordPress theme.

Post Formats is a theme feature introduced with the WordPress 3.1 release. It's piece of meta info that can be used by a theme to customize its post structure. If you ever used Tumblr, then you'll love this feature.

As of now, WordPress supports following post formats:

  • aside: Typically styled without a title. Similar to a Facebook note update.
  • gallery: An image gallery. This type of post will likely contain an image gallery using shortcode and plugins.
  • link: A link to an external webpage.
  • image: A single image. Yeah, just a single image.
  • quote: A quatation. My favorite quote is: Your arms are just too short to box with the God. - CM Punk to Dwayne "The Rock" Johnson
  • status: A short status update, similar to a tweet.
  • video: A single video or several videos. You can upload or embed a video to the post.
  • audio: An audeo file, likely if you run a Podcast.
  • chat: A chat transcript.

Add following snippet to your theme's functions.php file to add post format support to your post:

add_theme_support( 'post-formats', array( 'aside', 'chat','gallery','image','link', 'quote', 'status', 'video', 'audio' ) );

You can also add post format support to Page and custom post types:

// add post-formats to post_type 'page'
add_post_type_support( 'page', 'post-formats' );

// add post-formats to post_type 'my_custom_post_type'
add_post_type_support( 'my_custom_post_type', 'post-formats' );
Important: Check our new website TricksPanda.com for WordPress tutorials, plugins and more.
 
Powered by Blogger.