首页 WordPress函数大全 get_post_class()

get_post_class()

2020-05-01 / 3531阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

get_post_class( string|string[] $class = '', int|WP_Post $post_id = null )

Retrieves an array of the class names for the post container element.

描述

The class names are many. If the post is a sticky, then the ‘sticky’ class name. The class ‘hentry’ is always added to each post. If the post has a post thumbnail, ‘has-post-thumbnail’ is added as a class. For each taxonomy that the post belongs to, a class will be added of the format ‘{$taxonomy}-{$slug}’ – eg ‘category-foo’ or ‘my_custom_taxonomy-bar’.

The ‘post_tag’ taxonomy is a special case; the class has the ‘tag-‘ prefix instead of ‘post_tag-‘. All class names are passed through the filter, ‘post_class’, with the list of class names, followed by $class parameter value, with the post ID as the last parameter.

参数

$class

(string|string[])
(Optional)
Space-separated string or array of class names to add to the class list.

Default value: ''

$post_id

(int|WP_Post)
(Optional)
Post ID or post object.

Default value: null

返回

(string[]) Array of class names.

大家谈论
    我的见解