get_post_class
get_post_class ( $css_class = '', $post = null )
Parameters:- (string|string[]) css_class Optional. Space-separated string or array of class names to add to the class list. Default empty.
- (int|WP_Post) post Optional. Post ID or post object.
Returns:- (string[]) Array of class names.
Defined at:Change Log: - Introduced in WordPress: 2.7.0
- Deprecated in WordPress: —
Description
Retrieves an array of the class names for the post container element.The class names are many:
- If the post has a post thumbnail, `has-post-thumbnail` is added as a class.
- If the post is sticky, then the `sticky` class name is added.
- The class `hentry` is always added to each post.
- For each taxonomy that the post belongs to, a class will be added of the format
`{$taxonomy}-{$slug}`, e.g. `category-foo` or `my_custom_taxonomy-bar`.
The `post_tag` taxonomy is a special case; the class has the `tag-` prefix
instead of `post_tag-`.
All class names are passed through the filter, {@see 'post_class'}, followed by
`$css_class` parameter value, with the post ID as the last parameter.