Different Single Post Templates for Post Formats

So first of all, I editd init.php so that:

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

is not longer commented out.

Now, I want to make custom templates based on the content-single.php file for each post format. I’ve duplicated single.php and renamed it single-image.php. It includes the following code:

<?php get_template_part('templates/content', 'single-image'); ?>

I then duplicated content-single in the templates folder, and renamed it content-single-image.php. However, I cannot get posts of the ‘image’ post format to use this single template. If I follow the steps above, but instead create content-image, then the correct template is used on the blog page. What am I doing wrong which is preventing the correct template from being used on the single post page?

I don’t think that post formats use the same template hierarchy as custom post types. This would mean that single-image.php is never being loaded.

Instead change single.php to the following;

<?php get_template_part('templates/content-single', get_post_format()); ?>
4 Likes

That worked perfectly, thanks so much. Your method is much cleaner as well, since I won’t have to keep replicating single.php and cluttering the directory.