Fetch ACF Options Page Fields via REST API

Create a custom REST endpoint to expose ACF options page values — not available by default in the REST API.

php rest-api
|

Create a custom REST endpoint to expose ACF options page values — not available by default in the REST API.

ACF options pages don’t have a REST API representation by default. Register a custom endpoint:

<?php
add_action( 'rest_api_init', function () {
    register_rest_route( 'mysite/v1', '/options', [
        'methods'             => 'GET',
        'callback'            => function () {
            $options = [
                'company_name'    => get_field( 'company_name', 'option' ),
                'company_phone'   => get_field( 'company_phone', 'option' ),
                'company_email'   => get_field( 'company_email', 'option' ),
                'company_address' => get_field( 'company_address', 'option' ),
                'social_links'    => get_field( 'social_links', 'option' ),
            ];

            return rest_ensure_response( $options );
        },
        'permission_callback' => '__return_true',
    ] );
} );

Fetch from your front end:

GET /wp-json/mysite/v1/options

For a more dynamic approach that exposes all fields from a specific options page:

<?php
add_action( 'rest_api_init', function () {
    register_rest_route( 'mysite/v1', '/options/(?P<page>[\w-]+)', [
        'methods'             => 'GET',
        'callback'            => function ( $request ) {
            $page   = $request->get_param( 'page' );
            $fields = get_fields( $page );

            if ( ! $fields ) {
                return new WP_Error( 'no_fields', 'No fields found for this options page.', [ 'status' => 404 ] );
            }

            return rest_ensure_response( $fields );
        },
        'permission_callback' => function () {
            return current_user_can( 'edit_posts' );
        },
    ] );
} );

Usage with an authenticated request:

GET /wp-json/mysite/v1/options/option
GET /wp-json/mysite/v1/options/theme_settings

Note: The dynamic endpoint above requires authentication (edit_posts capability). Adjust the permission_callback based on your security requirements — use __return_true only for data that’s safe to expose publicly.

Related Snippets

Stay Updated

Get ACF tips and new extensions in your inbox

No spam. Unsubscribe anytime.