post_class()

最后更新于:2021-11-27 18:53:30

post_class( string|string[]$class=”, int|GC_Post$post_id=null)

Displays the classes for the post container element.

参数

$class

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

Default value: ”

$post_id

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

Default value: null

源文件

文件: gc-includes/post-template.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 ) ) ) . '"';
}
.post {
	/* Styles for all posts */
}

.post-4564 {
	/* Styles for only this post (ID number 4564) */
}

.category-news {
	/* Styles for all posts in the 'news' category  */
}

.format-standard {
	/* Styles for all posts assigned the post-format of 'standard'  */
}