Displaying post format icon next to the title in recent posts

I am creating a theme from scratch, and it’s going quite well so far, but I’ve been wondering if there is a way to display the post format (e.g. standard post, audio, video, image etc.) icon next to a post title when displaying the list of recent posts?

I would like the readers to know right away what kind of post they are about to read / listen to / see..

Read More

I know it’s possible to format whole posts based on their format, but couldn’t find anything regarding the links to them in a widget. I’m thinking it should be possible—if you can get the titles, why couldn’t you get the formats and their icons as well?

There definitely IS a way to do it .. somehow, because it’s exactly what this plugin does. However, it does it only for one post format, but how to add icons for all of them?

Related posts

Leave a Reply

2 comments

  1. It is possible. Adding

    <?php $format = get_post_format(); ?>
    

    in the loop will return the format of the post. e.g.

    <?php echo 'The post format is: ' . get_post_format(); ?>
    

    will return: The post format is: video. If the post format is the default one, it will return null.

    If you place the get_post_format() beside the post title, it should display what you want.