How to add Post Formats support to your theme

What is Post Format?

According to codex:

Post Formats is a theme feature introduced with Version 3.1. A Post Format is a piece of meta information that can be used by a theme to customize its presentation of a post.

How to add Post Formats in your theme?

I assume that you’re current theme doesn’t support post format, and you know your way on wordpress hook, php and html / css.

First, create a child theme

In the new function.php, add the following code:


add_action( 'after_setup_theme', 'wpsites_child_theme_posts_formats', 11 );
function wpsites_child_theme_posts_formats(){
add_theme_support( 'post-formats', array(
'aside',
'audio',
'chat',
'gallery',
'image',
'link',
'quote',
'status',
'video',
) );
}

In the index.php, single.php or category.php, you can use get_post_format() and subsequently a get_template() on content.php or any content-“formatname”.php you want to set up.

You can find more information here.

Posted in Wordpress Tagged with: , ,

Leave a Reply