函数原型
post_class( string|string[] $class = ”, int|WP_Post $post = null )
函数描述
Displays the classes for the post container element.
是否弃用
未弃用
函数参数
-
$class
string|string[]
Optional - One or more classes to add to the class list.
Default:
'' -
$post
int|WP_Post
Optional - Post ID or post object. Defaults to the global
$post.Default:
null
函数返回值
无
函数位置
File: wp-includes/post-template.php.
函数源码
function post_class( $class = '', $post = null ) {
// Separates classes with a single space, collates classes for post DIV.
echo 'class="' . esc_attr( implode( ' ', get_post_class( $class, $post ) ) ) . '"';
}
源码链接
变更日志
| Version | Description |
|---|---|
| 2.7.0 | Introduced. |

