Pergunta

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..

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?

Foi útil?

Solução

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.

Outras dicas

Howli doesn't answer the icon question. I did my homework and wrote some code but if my posts are paginated I don't know how to load the image since its URL changes every time you turn the page. Here is how it looks the first page of (paginated) post

It's in Spanish but you'll get the idea. After page 1 image link is broken since the png's url changes with pagination and I haven't solved that yet.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top