For your functions.php file in the theme.
add_theme_support( 'post-formats',
array(
'aside',
'gallery',
'link',
'image',
'quote',
'status',
'video',
'audio',
'chat'
)
);
add_post_type_support( 'post', 'post-formats' );
add_post_type_support( 'page', 'post-formats' );
// and other custom post types if you have them
Can i use my own post format, like a ” web site”?
I think it could be “link” post format too.
Why not work in p2theme?
How do I add more post-formats to p2 theme?
Thanks!
I see post formats as an option now, but it still doesn’t display correctly on the front end… any idea why?
Hey! Once the post formats are enabled, they still need to be called in a template in order to distinguish one format visually from another. For example, to display something specifically for a quote format, you could do something like this in your post template:
And, if you’re using
post_class()
on the post object (like in the loop), that gives you additional CSS classes to hook into:Full documentation here.
It’s 2024, and this php function still works. Thank you!
I copied and pasted this into a WP Code snippet. If you’re not a coding expert, I highly recommend using a code snippet plugin to insert anything experimental because it’s really easy to delete if it screws things up. Just make sure you’re only testing one code at a time.