post_class_taxonomies
Filter HookDescription
Filters the taxonomies to generate classes for each individual term. Default is all public taxonomies registered to the post type.Hook Information
File Location |
wp-includes/post-template.php
View on GitHub
|
Hook Type | Filter |
Line Number | 572 |
Hook Parameters
Type | Name | Description |
---|---|---|
string[]
|
$taxonomies
|
List of all taxonomy names to generate classes for. |
int
|
$post_id
|
The post ID. |
string[]
|
$classes
|
An array of post class names. |
string[]
|
$css_class
|
An array of additional class names added to the post. |
Usage Examples
Basic Usage
<?php
// Hook into post_class_taxonomies
add_filter('post_class_taxonomies', 'my_custom_filter', 10, 4);
function my_custom_filter($taxonomies, $post_id, $classes, $css_class) {
// Your custom filtering logic here
return $taxonomies;
}
Source Code Context
wp-includes/post-template.php:572
- How this hook is used in WordPress core
<?php
567 * @param string[] $taxonomies List of all taxonomy names to generate classes for.
568 * @param int $post_id The post ID.
569 * @param string[] $classes An array of post class names.
570 * @param string[] $css_class An array of additional class names added to the post.
571 */
572 $taxonomies = apply_filters( 'post_class_taxonomies', $taxonomies, $post->ID, $classes, $css_class );
573
574 foreach ( (array) $taxonomies as $taxonomy ) {
575 if ( is_object_in_taxonomy( $post->post_type, $taxonomy ) ) {
576 foreach ( (array) get_the_terms( $post->ID, $taxonomy ) as $term ) {
577 if ( empty( $term->slug ) ) {
PHP Documentation
<?php
/**
* Filters the taxonomies to generate classes for each individual term.
*
* Default is all public taxonomies registered to the post type.
*
* @since 6.1.0
*
* @param string[] $taxonomies List of all taxonomy names to generate classes for.
* @param int $post_id The post ID.
* @param string[] $classes An array of post class names.
* @param string[] $css_class An array of additional class names added to the post.
*/
Quick Info
- Hook Type: Filter
- Parameters: 4
- File: wp-includes/post-template.php
Related Hooks
Related hooks will be displayed here in future updates.