I've added a single Advanced Custom Field to the categories taxonomy (that appears to work as expected) and am trying to retrieve it along with the categories using the REST API, via /wp-json/wp/v2/categories.

I've managed to customise the posts JSON returned, using the rest_prepare_post filter...

function prepare_restful_posts($data, $post, $request) {
    // Do stuff to $data
add_filter('rest_prepare_post', 'prepare_restful_posts', 10, 3);

...but I can't seem to find any helpful information about how to customise the categories JSON.

Can someone possibly shed some light on this?

1 Answer 1


Turns out it's the helpfully titled rest_prepare_categoryfilter

function prepare_restful_categories($response, $item, $request) {
    // Do stuff to categories
add_filter('rest_prepare_category', 'prepare_restful_categories', 10, 3);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.