From c6a5d1192c4583ac4bb3c6a7f26aa037ba0f7117 Mon Sep 17 00:00:00 2001 From: markjaquith Date: Fri, 5 Nov 2010 06:48:56 +0000 Subject: [PATCH] Post Formats generate output in post_class() (format-foo), and body_class() (for single... single-format-foo). Now themers can support Post Formats with one line of PHP and by adding CSS! see #14746 git-svn-id: http://svn.automattic.com/wordpress/trunk@16200 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post-template.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index d75c680be4..1acd9f8a0e 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -327,6 +327,10 @@ function get_post_class( $class = '', $post_id = null ) { $classes[] = $post->post_type; $classes[] = 'type-' . $post->post_type; $classes[] = 'status-' . $post->post_status; + if ( get_post_format( $post->ID ) ) + $classes[] = 'format-' . sanitize_html_class( get_post_format( $post->ID ) ); + else + $classes[] = 'format-default'; // post requires password if ( post_password_required($post->ID) ) @@ -416,6 +420,10 @@ function get_body_class( $class = '' ) { $classes[] = 'single'; $classes[] = 'single-' . sanitize_html_class($post->post_type, $post_id); $classes[] = 'postid-' . $post_id; + if ( get_post_format( $post_id ) ) + $classes[] = 'single-format-' . sanitize_html_class( get_post_format( $post_id ) ); + else + $classes[] = 'single-format-default'; if ( is_attachment() ) { $mime_type = get_post_mime_type($post_id);