post_class
Filter HookDescription
Filters the list of CSS class names for the current post.Hook Information
File Location |
wp-includes/post-template.php
View on GitHub
|
Hook Type | Filter |
Line Number | 607 |
Hook Parameters
Type | Name | Description |
---|---|---|
string[]
|
$classes
|
An array of post class names. |
string[]
|
$css_class
|
An array of additional class names added to the post. |
int
|
$post_id
|
The post ID. |
Usage Examples
Basic Usage
<?php
// Hook into post_class
add_filter('post_class', 'my_custom_filter', 10, 3);
function my_custom_filter($classes, $css_class, $post_id) {
// Your custom filtering logic here
return $classes;
}
Source Code Context
wp-includes/post-template.php:607
- How this hook is used in WordPress core
<?php
602 *
603 * @param string[] $classes An array of post class names.
604 * @param string[] $css_class An array of additional class names added to the post.
605 * @param int $post_id The post ID.
606 */
607 $classes = apply_filters( 'post_class', $classes, $css_class, $post->ID );
608
609 return array_unique( $classes );
610 }
611
612 /**
PHP Documentation
<?php
/**
* Filters the list of CSS class names for the current post.
*
* @since 2.7.0
*
* @param string[] $classes An array of post class names.
* @param string[] $css_class An array of additional class names added to the post.
* @param int $post_id The post ID.
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/post-template.php
Related Hooks
Related hooks will be displayed here in future updates.