WordPress REST API (Version 2) 2.0-beta15 has 11 actions and 32 filters, read directly from its source code on Nov 17, 2026. The list updates automatically when a new version is released.
How to use these hooks
Actions let you run your own code at a specific moment. Filters let you change a value before the plugin uses it. Put your code in a child theme's functions.php or a code-snippets plugin, never in the plugin's own files, because updates overwrite them.
// Run your own code when WordPress REST API (Version 2) fires an action
add_action( 'rest_insert_attachment', function( $attachment, $request, $arg3 ) {
// Your code runs here.
}, 10, 3 );
// Change a value WordPress REST API (Version 2) is about to use
add_filter( 'get_the_excerpt', function( $post_excerpt, $post ) {
// Change $post_excerpt here.
return $post_excerpt;
}, 10, 2 );Parts of a name in {braces} are filled in at runtime (for example a post type or field ID). Choose Example on any hook for a ready-to-edit snippet.
All hooks
-
get_the_excerpt
filter/** * This filter is documented in wp-includes/post-template.php */ apply_filters( 'get_the_excerpt', $post->post_excerpt, $post ); -
get_the_guid
filter/** * This filter is documented in wp-includes/post-template.php */ apply_filters( 'get_the_guid', $post->guid ); -
/** * Fires after a single post is created or updated via the REST API. */ do_action( "rest_insert_{$this->post_type}", $post, $request, true ); -
/** * Fires after a single term is created or updated via the REST API. */ do_action( "rest_insert_{$this->taxonomy}", $term, $request, true ); -
rest_insert_attachment
action/** * Fires after a single attachment is created or updated via the REST API. */ do_action( 'rest_insert_attachment', $attachment, $request, true ); -
rest_insert_comment
action/** * Fires after a comment is created or updated via the REST API. */ do_action( 'rest_insert_comment', $comment, $request, true ); -
rest_insert_user
action/** * Fires after a user is created or updated via the REST API. */ do_action( 'rest_insert_user', $user, $request, true ); -
the_content
filter/** * This filter is documented in wp-includes/post-template.php */ apply_filters( 'the_content', $post->post_content ); -
the_excerpt
filter/** * This filter is documented in wp-includes/post-template.php */ apply_filters( 'the_excerpt', apply_filters( 'get_the_excerpt', $post->post_excerpt, $post ) ); -
query_vars
filter/** * Filter the publicly allowed query vars. */ apply_filters( 'query_vars', $wp->public_query_vars ); -
/** * Filter the query arguments for a request. */ apply_filters( "rest_{$this->post_type}_query", $args, $request ); -
/** * Filter whether a post is trashable. */ apply_filters( "rest_{$this->post_type}_trashable", $supports_trash, $post ); -
rest_{$this->taxonomy}_query
filter/** * Filter the query arguments, before passing them to `get_terms()`. */ apply_filters( "rest_{$this->taxonomy}_query", $prepared_args, $request ); -
rest_api_init
action/** * Fires when preparing to serve an API request. */ do_action( 'rest_api_init', $wp_rest_server ); -
rest_avatar_sizes
filter/** * Filter the REST avatar sizes. */ apply_filters( 'rest_avatar_sizes', array( 24, 48, 96 ) ); -
rest_comment_query
filter/** * Filter arguments, before passing to WP_Comment_Query, when querying comments * via the REST API. */ apply_filters( 'rest_comment_query', $prepared_args, $request ); -
rest_comment_trashable
filter/** * Filter whether a comment is trashable. */ apply_filters( 'rest_comment_trashable', ( EMPTY_TRASH_DAYS > 0 ), $comment ); -
/** * Fires after a single post is deleted or trashed via the REST API. */ do_action( "rest_delete_{$this->post_type}", $post, $response, $request ); -
/** * Fires after a single term is deleted via the REST API. */ do_action( "rest_delete_{$this->taxonomy}", $term, $response, $request ); -
rest_delete_comment
action/** * Fires after a comment is deleted via the REST API. */ do_action( 'rest_delete_comment', $comment, $response, $request ); -
rest_delete_revision
action/** * Fires after a revision is deleted via the REST API. */ do_action( 'rest_delete_revision', $result, $request ); -
rest_delete_user
action/** * Fires after a user is deleted via the REST API. */ do_action( 'rest_delete_user', $user, $response, $request ); -
/** * Filter a post before it is inserted via the REST API. */ apply_filters( "rest_pre_insert_{$this->post_type}", $prepared_post, $request ); -
/** * Filter term data before inserting term via the REST API. */ apply_filters( "rest_pre_insert_{$this->taxonomy}", $prepared_term, $request ); -
rest_pre_insert_comment
filter/** * Filter a comment before it is inserted via the REST API. */ apply_filters( 'rest_pre_insert_comment', $prepared_comment, $request ); -
rest_pre_insert_user
filter/** * Filter user data before inserting user via the REST API. */ apply_filters( 'rest_pre_insert_user', $prepared_user, $request ); -
/** * Filter the post data for a response. */ apply_filters( "rest_prepare_{$this->post_type}", $response, $post, $request ); -
/** * Filter a term item returned from the API. */ apply_filters( "rest_prepare_{$this->taxonomy}", $response, $item, $request ); -
rest_prepare_attachment
filter/** * Filter an attachment returned from the API. */ apply_filters( 'rest_prepare_attachment', $response, $post, $request ); -
rest_prepare_comment
filter/** * Filter a comment returned from the API. */ apply_filters( 'rest_prepare_comment', $response, $comment, $request ); -
rest_prepare_post_type
filter/** * Filter a post type returned from the API. */ apply_filters( 'rest_prepare_post_type', $response, $post_type, $request ); -
rest_prepare_revision
filter/** * Filter a revision returned from the API. */ apply_filters( 'rest_prepare_revision', $response, $post, $request ); -
rest_prepare_status
filter/** * Filter a status returned from the API. */ apply_filters( 'rest_prepare_status', $response, $status, $request ); -
rest_prepare_taxonomy
filter/** * Filter a taxonomy returned from the API. */ apply_filters( 'rest_prepare_taxonomy', $response, $taxonomy, $request ); -
rest_prepare_user
filter/** * Filter user data returned from the REST API. */ apply_filters( 'rest_prepare_user', $response, $user, $request ); -
rest_private_query_vars
filter/** * Filter the allowed 'private' query vars for authorized users. */ apply_filters( 'rest_private_query_vars', $wp->private_query_vars ); -
rest_query_var-{$var}
filter/** * Filter the query_vars used in `get_items` for the constructed query. */ apply_filters( "rest_query_var-{$var}", $prepared_args[ $var ] ); -
rest_query_vars
filter/** * Filter allowed query vars for the REST API. */ apply_filters( 'rest_query_vars', $valid_vars ); -
rest_the_post
filter/** * Filter the post. */ apply_filters( 'rest_the_post', $post_obj, $post ); -
rest_user_query
filter/** * Filter arguments, before passing to WP_User_Query, when querying users via * the REST API. */ apply_filters( 'rest_user_query', $prepared_args, $request ); -
wp_rest_server_class
filter/** * Filter the REST Server Class. */ apply_filters( 'wp_rest_server_class', 'WP_REST_Server' ); -
comment_text
filterapply_filters( 'comment_text', $comment->comment_content, $comment ); -
rest_preprocess_comment
filterapply_filters( 'rest_preprocess_comment', $prepared_comment, $request );
Generated from WordPress REST API (Version 2)'s GPL-licensed source code. Hooks inside bundled third-party libraries are not listed.
Can't find the right hook?
We can build the customisation for you. Describe what you need: