Home Forums Feature Requests Native ACF JSON API Reply To: Native ACF JSON API

    • Elliot

    • September 5, 2013 at 12:41 pm

    Hi @sirjonathan

    Looks like the simplest answer was hooking in and adding the custom fields like so:

    add_filter('json_api_encode', 'json_api_encode_acf');
    function json_api_encode_acf($response) 
        if (isset($response['posts'])) {
            foreach ($response['posts'] as $post) {
                json_api_add_acf($post); // Add specs to each post
        else if (isset($response['post'])) {
            json_api_add_acf($response['post']); // Add a specs property
        return $response;
    function json_api_add_acf(&$post) 
        $post->acf = get_fields($post->id);

    The code is so small that I could not charge for it. Maybe you could package it up into a WP plugin?


  • We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.