wp_insert_post_empty_content
Filter HookDescription
Filters whether the post should be considered "empty". The post is considered "empty" if both: 1. The post type supports the title, editor, and excerpt fields 2. The title, editor, and excerpt fields are all empty Returning a truthy value from the filter will effectively short-circuit the new post being inserted and return 0. If $wp_error is true, a WP_Error will be returned instead.Hook Information
File Location |
wp-includes/post.php
View on GitHub
|
Hook Type | Filter |
Line Number | 4529 |
Hook Parameters
Type | Name | Description |
---|---|---|
bool
|
$maybe_empty
|
Whether the post should be considered "empty". |
array
|
$postarr
|
Array of post data. |
Usage Examples
Basic Usage
<?php
// Hook into wp_insert_post_empty_content
add_filter('wp_insert_post_empty_content', 'my_custom_filter', 10, 2);
function my_custom_filter($maybe_empty, $postarr) {
// Your custom filtering logic here
return $maybe_empty;
}
Source Code Context
wp-includes/post.php:4529
- How this hook is used in WordPress core
<?php
4524 * @since 3.3.0
4525 *
4526 * @param bool $maybe_empty Whether the post should be considered "empty".
4527 * @param array $postarr Array of post data.
4528 */
4529 if ( apply_filters( 'wp_insert_post_empty_content', $maybe_empty, $postarr ) ) {
4530 if ( $wp_error ) {
4531 return new WP_Error( 'empty_content', __( 'Content, title, and excerpt are empty.' ) );
4532 } else {
4533 return 0;
4534 }
PHP Documentation
<?php
/**
* Filters whether the post should be considered "empty".
*
* The post is considered "empty" if both:
* 1. The post type supports the title, editor, and excerpt fields
* 2. The title, editor, and excerpt fields are all empty
*
* Returning a truthy value from the filter will effectively short-circuit
* the new post being inserted and return 0. If $wp_error is true, a WP_Error
* will be returned instead.
*
* @since 3.3.0
*
* @param bool $maybe_empty Whether the post should be considered "empty".
* @param array $postarr Array of post data.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/post.php
Related Hooks
Related hooks will be displayed here in future updates.