post_class( string|array $class = '', int|WP_Post $post_id = null )

Displays the classes for the post container element.


Description


Parameters

$class

(string|array) (Optional) One or more classes to add to the class list.

Default value: ''

$post_id

(int|WP_Post) (Optional) Post ID or post object. Defaults to the global $post.

Default value: null


Top ↑

Source

File: wp-includes/post-template.php

function post_class( $class = '', $post_id = null ) {
	// Separates classes with a single space, collates classes for post DIV
	echo 'class="' . join( ' ', get_post_class( $class, $post_id ) ) . '"';
}

Top ↑

Changelog

Version Description
2.7.0 Introduced.