Make WordPress Core


Ignore:
Timestamp:
08/13/2008 07:09:08 PM (16 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post-template.php

    r8637 r8638  
    159159    $post = &get_post( $id );
    160160    return ( !empty( $post->post_excerpt ) );
     161}
     162
     163/**
     164 * Echo the classes for the post div
     165 *
     166 * {@internal Missing Long Description}}
     167 *
     168 * @package WordPress
     169 * @subpackage Post
     170 * @since 2.7
     171 *
     172 @ param string $class One or more classes to add to the class list
     173 * @param int $post_id An optional post ID
     174 */
     175function post_class( $class = '', $post_id = null ) {
     176
     177    $classes = 'post';
     178
     179    if ( is_sticky($post_id) )
     180        $classes .= ' sticky';
     181
     182    if ( !empty($class) )
     183        $classes .= ' ' . $class;
     184
     185    $classes = apply_filters('post_class', $classes, $class, $post_id);
     186
     187    echo 'class="' . $classes . '"';
    161188}
    162189
Note: See TracChangeset for help on using the changeset viewer.