Advertisement

Add Post Formats to a WordPress Theme

Post formats is a popular feature that is part of the WordPress core; however, it isn’t activated by default. Adding theme support really means that you’re activating a built-in feature in your theme.

You can find a good, real-world example of post formats at Lisa Sabin-Wilson, as shown. The site separates the post formats, both in the menu navigation and in the individual post styling and icons used to designate the different formats. You also see the small video icon that used to designate video posts on the site.

image0.jpg

To add support for post formats in your WordPress theme, you first need to add the function call to your Theme Functions (functions.php) template. After you follow these few steps to make that happen, the magic occurs on the Add New Post page in your WordPress Dashboard. But first, follow the steps to add post formats support in your theme:

  1. From your Dashboard, choose Appearance→Editor.

  2. Click the Theme Functions (functions.php) file in the Templates list on the right to open the themes function file.

  3. In the text editor box, add the following function on a new line prior to the closing ?> tag: add_theme_support( 'post-formats', array( 'aside', 'chat','gallery','image','link', 'quote', 'status', 'video', 'audio' ) );

  4. Click the Update File button to save the changes made to the functions.php file.

The preceding code sample adds all nine of the available post formats to the theme. You don’t have to use all nine; you can simply include only those formats that you think you’ll use in your theme and leave out the rest.

You won’t notice an immediate change to your site when you save your new theme functions file with the post formats support added. To see what WordPress has added to your site, visit the Add New Post page by choosing Posts→Add New in the Dashboard.

A Format item under the Publish section on the right side of the page appears. Click the Edit link next to Format to designate a format for your post, as shown.

image1.jpg
blog comments powered by Disqus
Advertisement
Advertisement

Inside Dummies.com