WordPress at Your Fingertips

post_class() WP 1.0

Display the classes for the post div.

1 time — 0.004188 sec (very slow) | 50000 times — 10.89 sec (slow) | PHP 7.0.2, WP 4.4.1

No Hooks.

Return

null. Nothing.

Usage

post_class( $class, $post_id );
$class(string|string[])
One or more classes to add to the class list.
$post_id(int|WP_Post)
Post ID or post object.
Default: global $post

Changelog

Since 2.7.0 Introduced.

Code of post_class() WP 5.7.2

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

From tag: Decor (design, layout, styling, class)

More from category: Other Theme Functions

More from Template Tags: Posts, Pages, ...

No comments
    Log In