Filter hook 'rest_route_for_post'

in WP Core File wp-includes/rest-api.php at line 3197

View Source

rest_route_for_post

Filter Hook
Description
Filters the REST API route for a post.

Hook Information

File Location wp-includes/rest-api.php View on GitHub
Hook Type Filter
Line Number 3197

Hook Parameters

Type Name Description
string $route The route path.
WP_Post $post The post object.

Usage Examples

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

function my_custom_filter($route, $post) {
    // Your custom filtering logic here
    return $route;
}

Source Code Context

wp-includes/rest-api.php:3197 - How this hook is used in WordPress core
<?php
3192  	 * @since 5.5.0
3193  	 *
3194  	 * @param string  $route The route path.
3195  	 * @param WP_Post $post  The post object.
3196  	 */
3197  	return apply_filters( 'rest_route_for_post', $route, $post );
3198  }
3199  
3200  /**
3201   * Gets the REST API route for a post type.
3202   *

PHP Documentation

<?php
/**
	 * Filters the REST API route for a post.
	 *
	 * @since 5.5.0
	 *
	 * @param string  $route The route path.
	 * @param WP_Post $post  The post object.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/rest-api.php
Related Hooks

Related hooks will be displayed here in future updates.