WordPress at a glance

post_class() WP 1.0

Display the classes for the post div.

Works based on: get_post_class()
✈ 1 time = 0.004188s = very slow | 50000 times = 10.89s = slow PHP 7.0.2, WP 4.4.1

No Hooks.

Return

Nothing (null).

Usage

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

Code of post_class: wp-includes/post-template.php VER 4.9.8

<?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 ) ) . '"';
}

Related Functions

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

More from category: Other Theme Functions

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

No comments
    Hello, !     Log In . Register