Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Category, no return #75

Closed
fromdecember opened this issue Oct 5, 2016 · 3 comments
Closed

Category, no return #75

fromdecember opened this issue Oct 5, 2016 · 3 comments

Comments

@fromdecember
Copy link

I've looked through what some suggested, but I'm not sure I understand the solution.

I'm able to see ACF return on my wp-json/wp/v2/posts but I do not see any custom ACF I made for any category "wp-json/wp/v2/categories". I'm simply adding a "special_image" ACF with a image URL, but nada. Can you help?

@airesvsg
Copy link
Owner

airesvsg commented Oct 5, 2016

Hi @fromdecember,
Please read it: #43 (comment)
Thanks

@airesvsg airesvsg closed this as completed Oct 5, 2016
@fromdecember
Copy link
Author

I added that to my functions.php and nothing.

@airesvsg
Copy link
Owner

airesvsg commented Oct 5, 2016

You changed the name of the taxonomy?

function rest_prepare_customer( $response, $object ) {
    if ( $object instanceof WP_Term ) {
        $response->data['acf'] = get_fields( $object->taxonomy . '_' . $object->term_id );
    }

    return $response;
}

add_filter( 'rest_prepare_{my-taxonomy}', 'rest_prepare_customer', 10, 2 );

Replace {my-taxonomy} for taxonomy you need.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants