Custom Route with Regex?
-
Hello,
I am adding a custom route to the cache and noticed that GET requests for a single item were not being cached, so I’m wondering if I can, or need, do something like this?
function add_cachable_endpoints( $allowed_endpoints ) { $allowed_endpoints['bbp-api/v1][] = 'forums', $allowed_endpoints['bbp-api/v1][] = 'forums/(?P<id>\d+)', return $allowed_endpoints; } add_filter( 'wp_rest_cache/allowed_endpoints' , 'add_cachable_endpoints' , 100 , 1 );
In this case a call to
/wp-json/bbp-api/v1/forums/
works fine, but a call to/wp-json/bbp-api/v1/forums/7028
is not cached, so I’m wondering if this is supported… I assumed it would be since things like/wp-json/wp/v2/posts/1
are cached.Cheers,
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Custom Route with Regex?’ is closed to new replies.