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

Doesn't seems to work #12

Closed
baptistebriel opened this issue Sep 11, 2015 · 1 comment
Closed

Doesn't seems to work #12

baptistebriel opened this issue Sep 11, 2015 · 1 comment

Comments

@baptistebriel
Copy link

@baptistebriel baptistebriel commented Sep 11, 2015

Hello,
Thanks for this plugin! I installed it along with Advanced Custom Fields & WP REST API but looks like nothing is happening; the posts items in the JSON object doesn't have a meta value.

screen shot 2015-09-11 at 12 43 49

This is respectively, console.log(data); and console.log(data[0].meta);
I tried to disable the plugin, an activate it again with no success. Do you maybe have an idea?
Thanks!

@baptistebriel
Copy link
Author

@baptistebriel baptistebriel commented Sep 11, 2015

I came up with this to make it work:

function my_rest_prepare_post($data, $post, $request) {
    $_data = $data->data;

    $fiels = get_fields($post->ID);

    foreach ($fiels as $key => $value){
        $_data[$key] = get_field($key, $post->ID);
    }

    $data->data = $_data;
    return $data;
}

add_filter('rest_prepare_post', 'my_rest_prepare_post', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant