# Read-Only REST Endpoint for ACF Options

> Publishes selected fields from your ACF options pages at /wp-json/wpide/v1/site-options, so a headless front end or app can load site-wide settings.

- Type: PHP
- Runs: Run everywhere
- Category: [Custom Post Types & Fields](https://wpide.com/library/category/post-types/)
- Tags: acf, rest-api, options-page
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/acf-rest-options-endpoint/

## Code

```php
// Options fields that may be shared publicly.
$wpide_acf_public_options = array( 'phone', 'email', 'address', 'social_links' );

add_action( 'rest_api_init', function () use ( $wpide_acf_public_options ) {
    register_rest_route( 'wpide/v1', '/site-options', array(
        'methods'             => 'GET',
        'permission_callback' => '__return_true',
        'callback'            => function () use ( $wpide_acf_public_options ) {
            $data = array();

            foreach ( $wpide_acf_public_options as $name ) {
                $data[ $name ] = function_exists( 'get_field' ) ? get_field( $name, 'option' ) : null;
            }

            $response = rest_ensure_response( $data );
            $response->header( 'Cache-Control', 'public, max-age=300' );

            return $response;
        },
    ) );
} );
```

## Notes

Only list fields that are safe to make public. The response is cached by browsers for five minutes.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Read-Only REST Endpoint for ACF Options" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
