Add post_class() template function for emitting standard classes for post div. see #7457

git-svn-id: http://svn.automattic.com/wordpress/trunk@8638 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2008-08-13 19:09:08 +00:00
parent 15440186be
commit a9d35dafba
3 changed files with 29 additions and 2 deletions

View File

@@ -160,6 +160,33 @@ function has_excerpt( $id = 0 ) {
return ( !empty( $post->post_excerpt ) );
}
/**
* Echo the classes for the post div
*
* {@internal Missing Long Description}}
*
* @package WordPress
* @subpackage Post
* @since 2.7
*
@ param string $class One or more classes to add to the class list
* @param int $post_id An optional post ID
*/
function post_class( $class = '', $post_id = null ) {
$classes = 'post';
if ( is_sticky($post_id) )
$classes .= ' sticky';
if ( !empty($class) )
$classes .= ' ' . $class;
$classes = apply_filters('post_class', $classes, $class, $post_id);
echo 'class="' . $classes . '"';
}
/**
* Echo "sticky" CSS class if a post is sticky
*