Filter hook 'default_category_post_types'

in WP Core File wp-includes/post.php at line 5688

View Source

default_category_post_types

Filter Hook
Description
Filters post types (in addition to 'post') that require a default category.

Hook Information

File Location wp-includes/post.php View on GitHub
Hook Type Filter
Line Number 5688

Hook Parameters

Type Name Description
string[] $post_types An array of post type names. Default empty array.

Usage Examples

Basic Usage
<?php
// Hook into default_category_post_types
add_filter('default_category_post_types', 'my_custom_filter', 10, 1);

function my_custom_filter($post_types) {
    // Your custom filtering logic here
    return $post_types;
}

Source Code Context

wp-includes/post.php:5688 - How this hook is used in WordPress core
<?php
5683  		 *
5684  		 * @since 5.5.0
5685  		 *
5686  		 * @param string[] $post_types An array of post type names. Default empty array.
5687  		 */
5688  		$default_category_post_types = apply_filters( 'default_category_post_types', array() );
5689  
5690  		// Regular posts always require a default category.
5691  		$default_category_post_types = array_merge( $default_category_post_types, array( 'post' ) );
5692  
5693  		if ( in_array( $post_type, $default_category_post_types, true )

PHP Documentation

<?php
/**
		 * Filters post types (in addition to 'post') that require a default category.
		 *
		 * @since 5.5.0
		 *
		 * @param string[] $post_types An array of post type names. Default empty array.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/post.php
Related Hooks

Related hooks will be displayed here in future updates.