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

ACF post object relationship #126

Closed
MikeMilian opened this issue Apr 4, 2017 · 3 comments
Closed

ACF post object relationship #126

MikeMilian opened this issue Apr 4, 2017 · 3 comments

Comments

@MikeMilian
Copy link

MikeMilian commented Apr 4, 2017

I am trying to get the ACF field of the post object. I have 2 the same functions. And the settings for the ACF for both posttypes are the same. But only the first one works.

This one works
http://keiweek.appademic.nl/wp-json/wp/v2/event

add_filter('acf/rest_api/event/get_fields', function( $data, $request, $response ) {
    if ( $response instanceof WP_REST_Response ) {
        $data = $response->get_data();
    }
    if( isset( $data['acf'] ) ) {
        $data['acf']['locatie']->acf = get_fields( $data['acf']['locatie']->ID );
    }   
    return $data;
}, 10, 3 );

And this one doesn't work
http://keiweek.appademic.nl/wp-json/wp/v2/locatie

add_filter('acf/rest_api/locatie/get_fields', function( $data, $request, $response ) {
    if ( $response instanceof WP_REST_Response ) {
        $data = $response->get_data();
    }
    if( isset( $data['acf'] ) ) {
        $data['acf']['events']->acf = get_fields( $data['acf']['events']->ID );
    }   
    return $data;
}, 10, 3 );
@airesvsg
Copy link
Owner

airesvsg commented Apr 5, 2017

Hi @MikeMilian,
Please read it: #109
Thanks

@MikeMilian
Copy link
Author

Thx, but that function still not working for me. The strange thing is that de event (post type) filter works. But with the locatie (post type) not working.

Do you know something else I can try? Thanks a lot!

@kgrosvenor
Copy link

Does this work now

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

No branches or pull requests

3 participants