post_class WordPress Filter Hook

The post_class hook is used to add CSS classes to post elements. This is useful for creating different styles for different posts, or for targeting specific posts with CSS.

apply_filters( 'post_class', string[] $classes, string[] $class, int $post_id ) #

Filters the list of CSS class names for the current post.


Parameters

$classes

(string[])An array of post class names.

$class

(string[])An array of additional class names added to the post.

$post_id

(int)The post ID.


Top ↑

Source

File: wp-includes/post-template.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
2.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.