How to add custom endpoint for single post
-
I have custom endpoint which looks as follow:
product/v1/get/(?P<id>[0-9-]+)
I try to add this to wp_rest_cache/allowed_endpoints filter but it doesn’t work. Could you help?
Here is my full code:function wprc_add_acf_posts_endpoint( $allowed_endpoints ) {
if ( !isset( $allowed_endpoints[ 'product/v1' ] ) || !in_array( '/get/(?P<id>[0-9-]+)', $allowed_endpoints[ 'product/v1' ] ) ) {
$allowed_endpoints[ 'product/v1' ][] = '/get/(?P<id>[0-9-]+)';
}
return $allowed_endpoints;
}
add_filter( 'wp_rest_cache/allowed_endpoints', 'wprc_add_acf_posts_endpoint', 10, 1);
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How to add custom endpoint for single post’ is closed to new replies.