rest_pre_insert_(post_type)
Filters a post before it is inserted via the REST API.
The dynamic portion of the hook name, $this->post_type, refers to the post type slug.
Possible hook names include:
Usage
add_filter( 'rest_pre_insert_(post_type)', 'wp_kama_rest_pre_insert_post_type_filter', 10, 2 ); /** * Function for `rest_pre_insert_(post_type)` filter-hook. * * @param stdClass $prepared_post An object representing a single post prepared for inserting or updating the database. * @param WP_REST_Request $request Request object. * * @return stdClass */ function wp_kama_rest_pre_insert_post_type_filter( $prepared_post, $request ){ // filter... return $prepared_post; }
- $prepared_post(stdClass)
- An object representing a single post prepared for inserting or updating the database.
- $request(WP_REST_Request)
- Request object.
Changelog
Since 4.7.0 | Introduced. |
Where the hook is called
rest_pre_insert_(post_type)
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 1405
return apply_filters( "rest_pre_insert_{$this->post_type}", $prepared_post, $request );
wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php 656
return apply_filters( "rest_pre_insert_{$this->post_type}", $changes, $request );
Where the hook is used in WordPress
wp-includes/blocks/navigation.php 1632
add_filter( 'rest_pre_insert_wp_navigation', 'block_core_navigation_update_ignore_hooked_blocks_meta' );
wp-includes/default-filters.php 757
add_filter( 'rest_pre_insert_wp_template', 'inject_ignored_hooked_blocks_metadata_attributes' );
wp-includes/default-filters.php 758
add_filter( 'rest_pre_insert_wp_template_part', 'inject_ignored_hooked_blocks_metadata_attributes' );
wp-includes/default-filters.php 761
add_filter( 'rest_pre_insert_wp_navigation', 'update_ignored_hooked_blocks_postmeta' );