Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress The WordPress Template Hierarchy Page and Post Templates in WordPress Single Post and Post Format Templates

Robert Jakobson
Robert Jakobson
12,816 Points

The "Single Post and Post Format Templates" video did not mention post formats at all. Could you add a video on them?

Perhaps they are mentioned in other videos in more detail? I already know a fair bit on them but just in the wider interest of the viewers..

2 Answers

Robert Jakobson
Robert Jakobson
12,816 Points

Hi Zac, saw that a couple of videos later you did mention that.

By the way, I want to personally thank you for providing a concise, yet friendly introduction to WordPress. I am overviewing (and taking part) of your WP courses so I can use them to educate my team-mates and clients.

Really world-class quality :)

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Sorry about that, looks like it got cut!

What you would do is create custom templates with the following names:

  • format-aside.php
  • format-link.php
  • format-gallery.php
  • etc

Then in your single.php template you would write the following statement inside of the Loop:

get_template_part('format', get_post_format());

So you don't really have individual templates for each Post Type, but rather separately styled includes that go inside of the Loop and display different formats differently.

Nicolas Blanco Mattos
Nicolas Blanco Mattos
Courses Plus Student 2,545 Points

Sorry Zac Gordon , but This video remains incomplete...

Reading Wrodpress Developer Guide, you can see that you also need to register theme support for 'post-formats', and tell what post formats your theme is supporting... after that you can do what you answered above about the single.php file

Wordpress developer guide: https://developer.wordpress.org/themes/functionality/post-formats/

Nicolas Blanco Mattos
Nicolas Blanco Mattos
Courses Plus Student 2,545 Points

Ok, I guess a video was added at the end jeje sorry again. The last video of this chapter talks about post formats ;) thanks, now it's all clear